Slot text
Exact display strings roll through staggered reels while preserving shaped scripts and right-to-left text.
npx @swipeui/cli add slot-textWhen to use it
- Prices, balances or scores that should roll digit by digit when they change, like a slot machine.
- Exact formatted values such as "$1,234.50" where every character must be correct.
- Codes, times or labels that change one character at a time.
- Text in any script, including right-to-left and joined scripts.
When not to use it
- Numbers that should count through every value. Use Animated counter.
- Words that change entirely. Use Text morph.
- Static text. Use Text.
Installation
Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.
npx @swipeui/cli add slot-text- Adds
components/swipeui/ui/slot-text.tsxand 4 shared helpers. - Installs react-native-reanimated, clsx, tailwind-merge, react-native-worklets, class-variance-authority. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { SlotText } from '@/components/swipeui/ui/slot-text';
<SlotText text={balance} />;Examples
price switches a personal plan between monthly and yearly billing. gate rolls a departure from Gate B12 to Gate C04. joined slides and fades the complete Arabic message in one stable container, preserving joined letters without outgoing reels or clipped shaping. Yearly, Change gate and Change message controls stay outside. The app and website use the same boards and content.
API reference
SlotTextProps
| Prop | Type | Default | Description |
|---|---|---|---|
text | | — | Complete display text; no numeric conversion occurs. |
motion? | | | Local number/morph character. |
wrap? | | | Allow reels to wrap; turn off for countdowns and prices inside controls. |
className? | | — | Root classes. |
textClassName? | | | Text role classes. |
style? | | — | Native layout escape hatch. |
testID? | | — | Root identifier. |
Native view/input props not listed here pass through where the exported TypeScript type allows them.
Composition and behavior
- text is the exact string to show.
- textClassName sets the style (monospace body by default).
Use wrap={false} for a countdown or price inside a control. Wrapping remains enabled by default.
| Setting | Default | Behavior |
|---|---|---|
wrap | true | Set false to keep all reels on one line. |
Behavior and gestures
- Static; when text changes, each changed character rolls into place with a small stagger.
- Unchanged characters stay put, so the eye goes to what moved.
Accessibility
- The whole value is read once as a single label, never character by character.
- Joined scripts like Arabic stay as one run, so letters keep their shapes.
- Reduce Motion changes the text instantly.
Motion
- Uses the
numberandlayoutmotion roles, so it follows your app's feel. Passmotionto tune this one instance. - Characters roll with the number role; width changes use the layout role.
- Reduce Motion removes the roll.
- Joined scripts use one stable, unclipped run that slides and fades on replacement; no outgoing reel remains in layout.
Performance
- Only changed characters animate.
Notes for AI
- Pass the exact display string; nothing is parsed or rounded.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.