jbmui

ScrollTextFill

  • Interactive
  • scroll-driven

Scroll to bring text into focus, one character at a time. Keyboard scrolling, reversible progress, and reduced-motion support.

Scroll here ↓ · Focus and use ↓ / ↑ to rewind

Una idea toma forma. Letra por letra.

Install

npx shadcn@latest add @jbm/scroll-text-fill

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

Also installs @jbm/text-fill, @jbm/tokens.

Usage

Contained scroll fill
import { ScrollTextFill } from "@/jbm/ui/scroll-text-fill"<ScrollTextFill  text="Una idea toma forma. Letra por letra."  height={320}  distance={640}  style={{ fontSize: 40 }}/>// Self-contained scroll region; respects prefers-reduced-motion.

Props

Stage px
Declared at the documented defaults
Landscape
fill by 320
Vertical
fill by 320
Basis

The region is width 100% and exactly height (default 320, minimum 120) stage pixels tall; the scrollable content inside is height + distance. With reduced motion the height becomes auto: the text plus 24px padding on each side, with a minimum of height.

Self-contained, focusable scroll region that pins a TextFill in a sticky row and maps its own scroll position (0 at top, 1 at the bottom) to fill progress. Scrolling back rewinds; it never autoplays. Under reduced motion it renders the full text statically with no scroll region.

PropTypeDefaultDescription
classNamestringnoneClass name on the TextFill span.
styleCSSPropertiesnoneInline styles for the TextFill span; set fontSize here.
textstringrequiredThe sentence to fill; passed to TextFill.
dimColorstringnoneColor of characters not yet reached; passed to TextFill.
accentColorstringnoneColor of the leading wave; passed to TextFill.
textColorstringnoneFinal color of settled characters; passed to TextFill.
reducedMotionbooleannoneOverrides the system prefers-reduced-motion setting. True renders the complete text with auto height and no scrolling; undefined follows the system preference (and renders reduced on the server).
heightnumber320Height of the scroll viewport in stage pixels. Minimum 120; non-finite values fall back to 320.
distancenumber640Extra scroll distance in pixels beyond the viewport; the whole fill happens over this travel. Minimum 1; non-finite values fall back to 640.
labelstring"Scroll to fill the text"Accessible name of the scroll region.

Also accepts Omit<TextFillProps, "progress">.

QA checks

  • Scroll the region from top to bottom and back: fill tracks scroll position in both directions and is complete exactly at the bottom.
  • Focus the region with Tab and use ↓ / ↑ (and Page Down / Up): it scrolls and fills without scrolling the page (overscroll is contained).
  • Enable prefers-reduced-motion (or pass reducedMotion): the full ink text renders statically, the region is not focusable, and there is no scroll.
  • Check narrow screens: long text wraps inside the sticky row and stays vertically centered in the viewport.
  • Change text or height after mount and confirm progress recomputes (a ResizeObserver re-measures).