# @teft/viewport

> CSS viewport for Teft.

Latest version **5.2.1** (published 2024-05-21) · GPL-2.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @teft/viewport
pnpm add @teft/viewport
yarn add @teft/viewport
bun add @teft/viewport
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.2.1 |
| Published | 2024-05-21 |
| First published | 2019-05-13 |
| Weekly downloads | 0 |
| License | GPL-2.0-or-later |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 23.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Dekode Interaktiv AS |
| Maintainers | stian-overasen, peroks, walbo, olethomas |
| Keywords | teft, viewport |

## Links

- npm: https://www.npmjs.com/package/@teft/viewport
- Repository: https://github.com/DekodeInteraktiv/teft
- Homepage: https://github.com/DekodeInteraktiv/teft/tree/master/packages/viewport/README.md
- Issues: https://github.com/DekodeInteraktiv/teft/issues
- npm.io page: https://npm.io/package/@teft/viewport

## Recent versions

- 5.2.1 (latest) — 2024-05-21
- 5.1.0 (next) — 2024-03-03
- 5.1.2 — 2024-03-03
- 5.0.3 — 2024-03-01
- 0.1.0 — 2020-12-01
- 0.0.7-alpha.0 — 2019-11-12
- 0.0.6 — 2019-09-12
- 0.0.5 — 2019-06-26
- 0.0.4 — 2019-06-04
- 0.0.3 — 2019-05-22
- 0.0.2 — 2019-05-13

## README

<!--docs:
title: Viewport
section: global
path: /packages/viewport/
-->

# Viewport
Package provides default Teft aliases as custom media queries based on the most used [Gutenberg breakpoints](https://github.com/WordPress/gutenberg/blob/master/packages/base-styles/_breakpoints.scss) with mobile-first visibility helper classes. This package uses [custom media queries](https://preset-env.cssdb.org/features#custom-media-queries) PostCSS plugin and expects your setup to support it.

### Breakpoints & Media Query aliases

| Name     | Pixel Width | Alias                    |
| -------- | ----------- | ------------------------ |
| `mobile` | 480         | `--teft-viewport-mobile` |
| `small`  | 600         | `--teft-viewport-small`  |
| `medium` | 782         | `--teft-viewport-medium` |
| `large`  | 960         | `--teft-viewport-large`  |
| `wide`   | 1280        | `--teft-viewport-wide`   |
| `huge`   | 1440        | `--teft-viewport-huge`   |

## Installation

```sh
npm install @teft/viewport
```

## Usage

### Example: Use custom media alias in your css file

```css
@media (--teft-viewport-large) {
	.my-css {
		color: #000;
	}
}
```

### Example: Using the helper classes
In this example, we use the show visibility classes to show certain strings of text based on the device on which users view a page. If their browser meets the class's conditions, the element will be shown. If not, it will be hidden.
```html

<p class="show-for-small">This text is shown on small screens and up.</p>
<p class="show-for-medium">This text is shown on medium screens and up.</p>
<p class="show-for-large">This text is shown on large screens and up.</p>
<p class="show-for-wide">This text is shown on wide screens and up.</p>
<p class="show-for-huge">This text is shown on huge screens and up.</p>
```

```html
<p class="hide-for-small">This text is hidden on small screens and up.</p>
<p class="hide-for-medium">This text is hidden on medium screens and up.</p>
<p class="hide-for-large">This text is hidden on large screens and up.</p>
<p class="hide-for-wide">This text is hidden on wide screens and up.</p>
<p class="hide-for-huge">This text is hidden on huge screens and up.</p>
```

---
_Source: https://npm.io/package/@teft/viewport · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
