TextFill
A controlled character sweep from muted text through vermilion into ink. Drive progress with a slider, scroll, or a video timeline.
Install
npx shadcn@latest add @jbm/text-fillNeeds the @jbm entry in components.json; see Install once.
Also installs @jbm/tokens.
Usage
import { TextFill } from "@/jbm/ui/text-fill"<TextFill text="Una idea toma forma." progress={0.5} style={{ fontSize: 40 }} />// progress: 0–1, controlled; no internal timer.import { TextFill } from "@/jbm/ui/text-fill"import { useProgress } from "@/jbm/motion/hooks" // install @jbm/motion-hooks separately// Render inside a Remotion <Composition> or <Player>: hooks run in the component body.export function FillingText() { const progress = useProgress(0.2, 1, 2) return <TextFill text="Letra por letra." progress={progress} style={{ fontSize: 72 }} />}Props
- Stage
fluidInline text: width follows the container and height follows the wrapped lines at the inherited font size × 1.15 line-height. Nothing is fixed; set fontSize through style or a parent.
Inline span that colors each grapheme by progress: characters ahead of the sweep stay dim, a short accent wave (about three characters) leads, and settled characters turn to text color. Pure React with no timers, browser globals, or Remotion; the full text is also rendered once in a visually hidden span for assistive technology, and the colored copy is aria-hidden.
| Prop | Type | Default | Description |
|---|---|---|---|
text | string | required | The sentence to sweep. Split into words (whitespace preserved, words never break mid-word unless they overflow) and graphemes via Intl.Segmenter. |
progress | number | required | Fill progress from 0 (all dim) to 1 (all text color). Clamped to 0–1; non-finite values render as 0. Drive from a slider, scroll position, or a timeline. |
dimColor | string | color.line | Color of characters the sweep has not reached yet. |
accentColor | string | color.accent | Color of the leading wave between dim and settled characters; keep the vermilion accent. |
textColor | string | color.ink | Final color of settled characters, and of every character at progress 1. |
reducedMotion | boolean | false | When true, renders the complete text in textColor regardless of progress. |
style | CSSProperties | none | Inline styles merged over the defaults (Geist sans, weight 800, line-height 1.15, pre-wrap); set fontSize here. |
className | string | none | Class name on the outer span. |
QA checks
- Drag the progress slider through 0, about 0.5, and 1: all dim at 0, a dim → vermilion → ink gradient near the sweep front mid-way, and solid ink at 1 with no lingering accent.
- Check wrapping on a narrow screen: words stay whole and whitespace is preserved; very long words wrap anywhere instead of overflowing.
- With a screen reader, the sentence is read once from the hidden copy, not character by character.
- Set reducedMotion and confirm the full ink text renders at any progress.
- Try text with emoji or combining marks; each grapheme should color as one unit.