norph
Text that morphs into its next value. Shared letters slide, new ones fade in, and digits roll by place value. One Reanimated component for iOS, Android, and web.
Press a chip again to step it. Count and Price also take −, +, and Shuffle. Or type in the field.
Install
In an Expo app, expo install picks the Reanimated version that matches your SDK:
npx expo install @glpecile/norph react-native-reanimated react-native-workletsbunx expo install @glpecile/norph react-native-reanimated react-native-workletspnpm expo install @glpecile/norph react-native-reanimated react-native-workletsOutside Expo, add the same three packages with your package manager. norph ships TypeScript source for Metro, so it needs no native build of its own.
Use
import { MorphText } from '@glpecile/norph';
<MorphText style={{ fontSize: 24, alignSelf: 'flex-start' }}>
{count}
</MorphText>import { MorphText } from '@glpecile/norph';
// With Uniwind. Text classes style each
// glyph, layout classes the outer box.
<MorphText className="text-2xl font-semibold text-violet-600 self-start">
{count}
</MorphText>- children
- The text, a string or a number. A change morphs in place.
- style
- Text styles reach every glyph. Margins and alignment reach the outer box.
- className
- The same split, for apps that resolve classes on core components, such as Uniwind.
- numberOfLines
- Turns the morph off and renders plain text.
Behavior
- Shared letters slideThe old and new text keep what they share. New letters fade in and dropped ones fade out.
- Digits roll by place value99 to 100 rolls every digit, and 1.5 to 12.5 keeps the decimal point.
- Plain text at restThe first render does not animate. Between morphs the text is one plain Text.
- iOS, Android, and webOne Reanimated component, on the web through react-native-web.
- Reduced motionThe text swaps with no animation when the system asks for less motion.
- Screen readersThey read the whole string once, never one glyph at a time.
One line: the text never wraps. Text too long for its box ends in an ellipsis.