Slot text
Text and numbers that spin into their new value on staggered slot machine reels.
npx shadcn@latest add @silicon-ui/slot-textInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/slot-textManually
Install the dependencies.
npm install motionCopy these files into your project. Shared files are skipped if you already have them.
components/silicon-ui/slot-text/slot-text.tsxcomponents/silicon-ui/slot-text/slot-text.module.css
Install the foundation once per app for the design and motion tokens:
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
| Prop | Type | Default |
|---|---|---|
value*The value to show. Numbers pass through format; strings render as they are. | string | number | — |
formatFormats a number value. Defaults to en-US grouping, so 12480 reads 12,480. | (value: number) => string | — |
durationSeconds the first reel spins. Later reels add stagger. | number | .9 |
staggerSeconds between reels stopping, left to right. | number | .07 |
spinsExtra full turns a digit makes before it lands. 0 rolls straight to the new digit. | number | 1 |
alignWhich end reels are matched from when the length changes. Numbers default to end, so 999 to 1,000 grows on the left. | "start" | "end" | — |
announceAnnounce new values politely to screen readers. | boolean | false |
className | string | — |
style | CSSProperties | — |
Dependencies
- npm
- motion
- Registry
- None