blinds
A heading printed across real 3D slats that turn over in a wave, lit and casting shadows, to show it.
Atelier Nord · Interiors, Copenhagen
Quiet rooms, loud ideas.
Homes and small hotels designed around daylight, oak and the people who live in them.
Live preview needs WebGPU or WebGL 2. 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.
This example failed to draw.
Every switch and slider plays it again; move the pointer across the open heading to nudge the slats.
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. The tabs below are the example above, with the values you set.
To change its code, copy the source into your effects folder; the copy replaces the built-in.
npx @dioramajs/diorama add blinds<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>import { start } from '@dioramajs/diorama'
const app = start()app.attach('.bl-headline', 'blinds', { style: 'horizontal', trigger: 'view', gap: 2, duration: 0.9, stagger: 0.07, light: 315,})import { start } from '@dioramajs/diorama'import blinds from '@dioramajs/text/blinds'
const app = start()app.attach('.bl-headline', blinds({ style: 'horizontal', trigger: 'view', gap: 2, duration: 0.9, stagger: 0.07, light: 315,}))Page transitions
Leaving a page the slats close again in reverse and fade; entering one, they open as the page comes in. How a flight flies.
Params
Every param is also an attribute, and both app.attach() and the handle take it by name.
| Param | Type | Default | Description |
|---|---|---|---|
stylerebuildsdata-dio-style | 'horizontal' | 'vertical' | 'tiles' | 'horizontal' |
|
triggerrebuildsdata-dio-trigger | 'view' | 'scroll' | 'hover' | 'view' |
|
slatsrebuildsdata-dio-slats | number2 to 16 | 6 | Slats per line of text, top to bottom; vertical slats and tiles get a like size. |
gapdata-dio-gap | number0 to 8 px | 2 | Space between neighboring slats while they turn; 0 closes them edge to edge. |
durationdata-dio-duration | number0.2 to 2.5 s | 0.9 | Time one slat takes to turn over. |
staggerdata-dio-stagger | number0 to 0.3 s | 0.07 | Time between one slat starting to turn and the next, shortened on long waves. |
delaydata-dio-delay | number0 to 2 s | 0 | Wait before the first slat turns, with trigger view. |
thresholddata-dio-threshold | number0 to 1 | 0.3 | Share of the heading in view before it opens, with trigger view or scroll. |
angledata-dio-angle | number0 to 180° | 65 | Turn of the slats at rest with trigger hover: 180 closed on their back, 90 edge-on, 0 open. |
lightdata-dio-light | number0 to 360° | 315 | Where the light comes from as a CSS angle, 0 above and 90 right. |
backdata-dio-back | color | 'currentColor' | Color of the slats' backs and edges; currentColor uses the text color. |
reverserebuildsdata-dio-reverse | string | '' | Text printed on the backs, a second message on the closed panel; empty leaves them plain. |
Params marked rebuilds re-run the effect's setup when they change, so set them before the element shows.
Inputs and frames
It reads delta, height, presence, progress, size and 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. How a frame is decided.
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.
To change what reduced motion does, patch it in start().
import { start } from '@dioramajs/diorama'
start({ effects: { blinds: { reducedMotion: 'static' } } })Cost and quality
- Download
- 12.1 KB min+gzip 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.
- Frames
- Idle at rest
It runs from the low tier up. Each tier changes this: The quality plugin picks the tier for each device.
| Tier | What changes |
|---|---|
low | The text is rastered at 1 device pixel per CSS pixel instead of 2. |
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.
Forno Lume · bakery and coffee
Open
Every day from 7 to 15, Rua das Flores 28
Live preview needs WebGPU or WebGL 2. A bakery's sign in red that reads Closed until the pointer turns its slats over to Open.
This example failed to draw.
<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.
Made by hand, slowly.
Every blanket is woven on a 1930s loom in the valley, eight a day, from the wool of the farms around it.
Live preview needs WebGPU or WebGL 2. A weaving mill's section heading on dark green cards that flip over in a diagonal ripple as it scrolls up the page.
This example failed to draw.
<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.
<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.