text animations
Text Morph
Shared-layout character morphing between two strings — individual letters animate to their new positions with spring physics.
Installation
Usage
Anatomy
Good to know
- It animates when
childrenchanges. Pass a string from state and update it. - Letters shared between the old and new text move into place; the others fade out and in.
- Screen readers get the current text through
aria-label; the animated letters are hidden from them. - When the user has turned on reduced motion, the new text replaces the old one instantly, with no morph.
Props
Examples
Word Cycler
A button group selects the active word and passes it as children. Characters shared between words animate smoothly to their new positions.
Auto-Cycling Plan Name
An interval drives the children prop through an array. The tighter spring transition creates a snappier feel suitable for compact UI.
Morphing Placeholder
The placeholder string cycles as the user types, morphing character-by-character. Controlled by query.length % suggestions.length so each keystroke advances the suggestion.