# blinds

A heading printed across real 3D slats that turn over in a wave, lit and casting shadows, to show it.

The heading starts behind a closed panel of slats in a solid color, like a shutter or a flip sign. The slats turn over one after another, each a thin board in perspective whose painted back and edges catch the light, casting thin shadows on its neighbors and on the page, until the text lies flat and readable. Horizontal slats turn like venetian blinds, vertical ones like a shop shutter, and square tiles flip in a diagonal ripple like a stadium card display. The pointer nudges the slats near it, and the nudge runs on through the others before they settle. A second text can be printed on the backs, so the turn switches between two messages.

Module `text`, category Text. Import `@dioramajs/text/blinds`. [Source](https://github.com/MasterKurosava/diorama/blob/main/packages/text/src/blinds.ts)

An interior studio's headline behind closed oak blinds whose slats turn over one after another, lit and casting thin shadows, until the text lies flat.

```html title="index.html"
<section class="bl-hero">
  <p class="bl-kicker">Atelier Nord · Interiors, Copenhagen</p>
  <h2 class="bl-headline" data-dio="blinds" data-dio-back="#a8744a">Quiet rooms, loud ideas.</h2>
  <p class="bl-line">Homes and small hotels designed around daylight, oak and the people who live in them.</p>
</section>
```

## Usage

Put it on: a heading or short text in a large font, on a solid page background. Not img, video, canvas, svg or form fields.

`start()` registers `blinds`, so the attribute alone puts it on an element.

```html
<h1 data-dio="blinds">Quiet rooms, loud ideas.</h1>
```

In page transitions: Leaving a page the slats close again in reverse and fade; entering one, they open as the page comes in.

## Params

| Name | Attribute | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `style` (rebuilds) | `data-dio-style` | `'horizontal' \| 'vertical' \| 'tiles'` | `'horizontal'` | horizontal turns strips like blinds; vertical turns upright slats; tiles flips cards. |
| `trigger` (rebuilds) | `data-dio-trigger` | `'view' \| 'scroll' \| 'hover'` | `'view'` | view opens it once in view; scroll opens with the scroll; hover opens near the pointer. |
| `slats` (rebuilds) | `data-dio-slats` | `number` 2 to 16 | `6` | Slats per line of text, top to bottom; vertical slats and tiles get a like size. |
| `gap` | `data-dio-gap` | `number` 0 to 8 px | `2` | Space between neighboring slats while they turn; 0 closes them edge to edge. |
| `duration` | `data-dio-duration` | `number` 0.2 to 2.5 s | `0.9` | Time one slat takes to turn over. |
| `stagger` | `data-dio-stagger` | `number` 0 to 0.3 s | `0.07` | Time between one slat starting to turn and the next, shortened on long waves. |
| `delay` | `data-dio-delay` | `number` 0 to 2 s | `0` | Wait before the first slat turns, with trigger view. |
| `threshold` | `data-dio-threshold` | `number` 0 to 1 | `0.3` | Share of the heading in view before it opens, with trigger view or scroll. |
| `angle` | `data-dio-angle` | `number` 0 to 180° | `65` | Turn of the slats at rest with trigger hover: 180 closed on their back, 90 edge-on, 0 open. |
| `light` | `data-dio-light` | `number` 0 to 360° | `315` | Where the light comes from as a CSS angle, 0 above and 90 right. |
| `back` | `data-dio-back` | `color` | `'currentColor'` | Color of the slats' backs and edges; currentColor uses the text color. |
| `reverse` (rebuilds) | `data-dio-reverse` | `string` | `''` | Text printed on the backs, a second message on the closed panel; empty leaves them plain. |

Changing a param marked rebuilds re-runs the effect setup.

### Variants

- `style`: `horizontal`, `vertical`, `tiles`
  - `horizontal` turns strips like blinds.
  - `vertical` turns upright slats.
  - `tiles` flips cards.
- `trigger`: `view`, `scroll`, `hover`
  - `view` opens it once in view.
  - `scroll` opens with the scroll.
  - `hover` opens near the pointer.

## Inputs and frames

Reads [`delta`](/docs/api/inputs#input-delta), [`height`](/docs/api/inputs#input-height), [`presence`](/docs/api/inputs#presence), [`progress`](/docs/api/inputs#progress), [`size`](/docs/api/inputs#size), [`y`](/docs/api/inputs#input-y). Draws only while something on it moves, then stops. Only while slats turn or settle after the pointer: with trigger view while the wave runs, with scroll while scrolling, with hover while slats follow the pointer; none at rest. See [how a frame is decided](/docs/concepts/frames).

## Reduced motion and touch

With reduced motion it is off and the element shows as plain HTML. Off: the text is shown as it is, and the engine does not load for it.

Runs on every device. View and scroll work the same; a moving finger nudges the slats. With trigger hover a tap opens every slat in a ripple from the finger, and the next tap closes them.

```ts
import { start } from '@dioramajs/diorama'

start({ effects: { blinds: { reducedMotion: 'static' } } })
```

## Cost and quality

Loads 12.1 KB the first time a page uses it. GPU: One instanced draw of a box per slat, up to 2048, and a shadow quad over the panel that tests up to nine slats per pixel; nothing at rest. Memory: The text raster at twice its CSS size, the second text if any, and a small table of slat angles.

- low: The text is rastered at 1 device pixel per CSS pixel instead of 2.

See [the quality plugin](/docs/effects/quality).

## Recipes

### A flip sign with two messages

`data-dio-reverse` prints a second text on the backs of the slats, so the closed panel reads as one message and the open one as the other. With `data-dio-trigger="hover"` and `angle="180"` the sign rests closed on its back and turns over where the pointer is; `back` paints the backs, and the second text takes whichever of the page and the text color stands out on it. On a phone a tap turns the whole sign over in a ripple from the finger, and the next tap turns it back.

A bakery's sign in red that reads Closed until the pointer turns its slats over to Open.

```html title="index.html"
<div class="bl-shop">
  <p class="bl-shop-name">Forno Lume · bakery and coffee</p>
  <h2 class="bl-sign" data-dio="blinds" data-dio-trigger="hover" data-dio-angle="180" data-dio-back="#c8361f" data-dio-reverse="Closed">Open</h2>
  <p class="bl-shop-hours">Every day from 7 to 15, Rua das Flores 28</p>
</div>
```

The element’s own text is the one screen readers read, search engines index and find in page finds: put the message that matters there and the alternative on the backs.

### A card display wave on the scroll

`style="tiles"` cuts the heading into square cards that flip over their diagonal in a ripple from the top left corner, like a stadium card display. With `data-dio-trigger="scroll"` the ripple follows the scroll both ways: it starts once `threshold` of the heading is in view and lies flat when the heading reaches the middle of the viewport. Scroll past this example to see it.

A weaving mill's section heading on dark green cards that flip over in a diagonal ripple as it scrolls up the page.

```html title="index.html"
<section class="bl-mill">
  <h2 class="bl-mill-title" data-dio="blinds" data-dio-style="tiles" data-dio-trigger="scroll" data-dio-back="#1f4e3d">Made by hand, slowly.</h2>
  <p class="bl-mill-line">Every blanket is woven on a 1930s loom in the valley, eight a day, from the wool of the farms around it.</p>
</section>
```

### A shop shutter for a launch

`style="vertical"` turns upright slats from left to right, like a shutter opening in front of a shop window. A bright `back` against a dark page reads as a painted shutter; `stagger` sets how fast the opening runs along the line.

```html
<h1 data-dio="blinds" data-dio-style="vertical" data-dio-back="#ffcf3a" data-dio-stagger="0.05">Opening night</h1>
```

## Notes

The slats are thin boards built in 3D and seen in perspective from in front of the heading, not a mask over flat text. Each one turns about its own axis and stands out of the page as it turns, so its edge catches the light and it casts a soft shadow on the slat next to it and on the page, longer the further it stands out. The lamp sits above the page on the side `light` names, and faces turned toward it brighten while faces turned away darken. The front of a slat is cut from the page’s own background color, which fades in as it turns, so put the effect on a heading over a solid background; over an image or a gradient the fronts stay clear and only the letters turn.

When the wave is over, and between nudges of the pointer, the heading is real, selectable text again and the effect draws no frames. With the view trigger a heading the visitor has already seen stays as it is, and one on the first screen opens behind the page’s intro. With the hover trigger the slats rest at `angle`, drawn, until the pointer comes near; `angle="0"` rests open. Under reduced motion the text is shown as it is and the engine does not load for it.

Leaving a page the slats close again and fade; entering one, they open as the page comes in. The element is hidden behind its copy while it is drawn, its own background too: put a background behind the heading on a parent. The canvas cannot draw `background-clip: text`, `text-shadow`, `-webkit-text-stroke` or vertical writing modes the way the browser does: an element with any of them keeps its text as it is, and a warning in development names the reason. `style`, `trigger`, `slats` and `reverse` rebuild the effect when they change; the other params change live.

## Related

- [assemble](/docs/effects/assemble.md): Thousands of lit particles fly out of the depth around the page and gather into a heading.
- [counter](/docs/effects/counter.md): Stats count up to their value on real 3D mechanics: odometer drums, slot machine reels or flip cards.
- [dust](/docs/effects/dust.md): A heading crumbles into fine sand that lifts off the page and drifts away in depth as it scrolls out, or on a click.
- [emboss](/docs/effects/emboss.md): Letters pressed into or raised out of paper, leather, brushed metal, stone or plaster, lit by a light that follows the pointer.
- [extrude](/docs/effects/extrude.md): A headline becomes a solid 3D block: beveled letters with lit side walls, seen in perspective, that turn toward the pointer.
- [fire](/docs/effects/fire.md): The letters burn: flames rise from their tops, sparks drift up in depth and the firelight flickers on the page.
- [hologram](/docs/effects/hologram.md): A heading becomes a 3D hologram: projected from a glowing emitter, built of slices in depth, crossed by scan lines.
- [inflate](/docs/effects/inflate.md): Letters puff up into round 3D shapes, like balloons or soft clay, that dent and wobble under the pointer.
- [Reduced motion](/docs/guides/reduced-motion.md)
- [Performance and quality](/docs/guides/performance.md)
