ScrollTextFill
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
Install
npx shadcn@latest add @jbm/scroll-text-fillNeeds the @jbm entry in components.json; see Install once.
Also installs @jbm/text-fill, @jbm/tokens.
Usage
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 ofheight.
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.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | none | Class name on the TextFill span. |
style | CSSProperties | none | Inline styles for the TextFill span; set fontSize here. |
text | string | required | The sentence to fill; passed to TextFill. |
dimColor | string | none | Color of characters not yet reached; passed to TextFill. |
accentColor | string | none | Color of the leading wave; passed to TextFill. |
textColor | string | none | Final color of settled characters; passed to TextFill. |
reducedMotion | boolean | none | Overrides 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). |
height | number | 320 | Height of the scroll viewport in stage pixels. Minimum 120; non-finite values fall back to 320. |
distance | number | 640 | Extra scroll distance in pixels beyond the viewport; the whole fill happens over this travel. Minimum 1; non-finite values fall back to 640. |
label | string | "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).