jbmui

TextFill

  • UI
  • adjustable

A controlled character sweep from muted text through vermilion into ink. Drive progress with a slider, scroll, or a video timeline.

Una idea toma forma. Letra por letra.

Install

npx shadcn@latest add @jbm/text-fill

Needs the @jbm entry in components.json; see Install once.

Also installs @jbm/tokens.

Usage

Half-filled sentence
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.
Drive it from a Remotion timeline
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
fluid

Inline 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.

PropTypeDefaultDescription
textstringrequiredThe sentence to sweep. Split into words (whitespace preserved, words never break mid-word unless they overflow) and graphemes via Intl.Segmenter.
progressnumberrequiredFill 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.
dimColorstringcolor.lineColor of characters the sweep has not reached yet.
accentColorstringcolor.accentColor of the leading wave between dim and settled characters; keep the vermilion accent.
textColorstringcolor.inkFinal color of settled characters, and of every character at progress 1.
reducedMotionbooleanfalseWhen true, renders the complete text in textColor regardless of progress.
styleCSSPropertiesnoneInline styles merged over the defaults (Geist sans, weight 800, line-height 1.15, pre-wrap); set fontSize here.
classNamestringnoneClass 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.