SwipeUI

Text morph

Per-character label replacement with intrinsic width transitions and shaped-run fades.

npx @swipeui/cli add text-morph
Variant
Preset
Material
Scheme
Feel
Real free component with a browser animation bridge. Native motion, haptics and materials need a device.

When to use it

  • Button or status labels that change, like Follow → Following or Send → Sent.
  • Small headings that swap words, where a smooth change feels polished.
  • Labels whose width changes and shouldn't jump.

When not to use it

  • Numbers. Use Slot text or Animated counter.
  • Long paragraphs.
  • Text that changes constantly; the motion becomes noise.

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 text-morph
  • Adds components/swipeui/ui/text-morph.tsx and 4 shared helpers.
  • Installs react-native-reanimated, react-native-worklets, clsx, tailwind-merge, class-variance-authority. In Expo apps it uses npx expo install so versions match your SDK.

Usage

app/settings.tsx
import { TextMorph } from '@/components/swipeui/ui/text-morph';

<TextMorph text={saved ? 'Saved' : 'Save'} />;

Examples

button morphs Save changes → Saving → Saved inside its primary action (wrap={false}). Tap Saved to reset. status shows a sync row with an outside Sync now control. The app and website use the same boards and content.

API reference

TextMorphProps

PropTypeDefaultDescription
textstring—

Next complete label; unchanged character slots retain identity.

motion?MotionOverride—

Shared morph feel.

wrap?booleantrue

Lets characters wrap onto more lines when space runs out. Turn it off inside controls that size to their label, such as buttons, so the label keeps one line.

className?string—

Root classes.

textClassName?string'text-body'

Text role classes.

style?StyleProp<ViewStyle>—

Native layout escape hatch.

testID?string—

Root ID.

Native view/input props not listed here pass through where the exported TypeScript type allows them.

Composition and behavior

  • text is the current label.
  • textClassName sets the style (body by default).

Behavior and gestures

  • Static; when text changes, characters that stay keep their place and new ones fade in.
  • The label's width eases to fit the new text.

Accessibility

  • Screen readers hear the complete new label.
  • Emoji and joined scripts stay intact.
  • Reduce Motion swaps text instantly.

Motion

  • Uses the morph motion role, so it follows your app's feel. Pass motion to tune this one instance.
  • Uses the morph role for characters and width.
  • Reduce Motion turns it off.

Performance

  • Only changed characters mount or unmount.

Notes for AI

  • Pass the next label as text; keep labels short.

Compatibility

Runs onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items