Roll Type
Short phrases taking turns word by word, each word rolling up off an unseen drum through glass as the next phrase rolls in.
Three short phrases take turns, a new one every 2.08 seconds. Each word rolls up out of sight and folds flat as the next phrase rolls in from below, overshoots its place and settles. The ground cuts hard to each phrase's colour.
How it works
Words move one at a time, 100ms apart in reading order.
- Leaving. A word's ink centre rises to the top line over 280ms and folds flat over the last 120ms, its top leaning toward the centre line as if it turned away on a drum.
- Arriving. 460ms after a phrase starts leaving, the next one's words rise from a flat line near the bottom, unfold downward from their tops, overshoot by about 4% and settle over 480ms.
- The cut. 600ms after a phrase starts leaving, the ground cuts to the new phrase's colour, and any word still leaving disappears with it.
- Glass. Every word is drawn from a sprite of itself, at rest and in motion alike. Its speed is measured on the ink centre over three frames and eased. By that amount, the sprite is cut into 28 strips that magnify the middle, as through a glass rod lying along the word, and two hues split up to 3.5 pixels to each side along the motion under it, 7 apart in all.
The motion is three small tables authored at 25 frames a second and read at a fractional key every frame, so it plays smooth at the screen's rate. Each word gets one affine matrix: a scale, a lean and a move. The tables describe a roll, not the letters, so any words work.
It pauses off screen and on a hidden tab. Under reduced motion it draws the first phrase at rest once. The canvas pixel ratio is capped at 2, and everything is cleaned up on unmount.
Installation
Usage
import RollType from "@/components/ui/roll-type";
<div className="aspect-video">
<RollType
phrases={[
{
lines: [["Design", "with"], ["taste"]],
ground: "#2430ff",
ink: "#f2efe6",
fringe: ["#7dfcff", "#ff4fd8"],
},
{
lines: [["Agents"], ["just", "get", "it"]],
ground: "#ff5a24",
ink: "#1a0c06",
},
]}
/>
</div>;The effect fills its box and is drawn for 16:9. Each phrase is one or two lines of words, set centred and sized so a capital is 102 scene pixels tall. The type comes from --font-sans, and the layout is measured from the live font. A plain grotesque reads best.
| Prop | Default | What it changes |
|---|---|---|
phrases | three phrases on ultramarine, vermilion and black | The phrases, each with lines, a ground, an ink and an optional pair of fringe hues. |
weight | 500 | The weight the face is drawn at. |
speed | 1 | Playback rate. |
fontVar | --font-sans | The CSS variable holding the font family. |
In params.ts, STAGGER_MS sets the delay between words, PHRASE_MS the time between phrases, GLASS_SPEED the speed at which the glass is at full strength, and LENS and FRINGE the bend and the colour split. Set the last two to 0 to turn them off.