Sora UI

Text Morph

Per-character layout morphing and place-value number transitions for labels, counters, and live text swaps, powered by Web Animations API and FLIP. React component.

Made by Axyl
Loading...

Per-character layout morph between Copy and Copied — click the button to trigger a swap.

Examples

Processing Transaction

Loading...

Transaction status pill toggling between Processing Transaction and Transaction Safe with smooth layout morphing.

Text Morph Input

Loading...

TextMorph driven by a live input field — type to see characters morph in real time.

Installation

npx shadcn@latest add @soralabs/text-morph

File Structure

text-morph.tsx
defs.ts
styles.ts
easing.ts
layout.ts
segments.ts
runtime.ts

Usage

Cycle copy on click:

Live morph while typing:

Props

PropTypeDefault
children?
ReactNode
-
as?
ElementType
"span"
duration?
number
400
ease?
string | SpringParams
"cubic-bezier(0.19, 1, 0.22, 1)"
scale?
boolean
true
numbers?
boolean
true
decimals?
number
-
locale?
Intl.LocalesArgument
"en"
cursorIndex?
number
-
respectReducedMotion?
boolean
true
charClassName?
string
-
live?
"off" | "polite" | "assertive"
"off"
className?
string
-

When to Use

Use TextMorph for label swaps that need to feel fluid rather than abrupt: copy buttons toggling "Copy" → "Copied", tab selectors, status badges, or counters where a hard cut feels jarring. It is most effective on short text (1–15 characters) where individual character transitions are clearly visible.

For longer text or entire paragraphs that change, a fade transition is simpler and more legible.

Accessibility

Set live="polite" when the content change is the result of a user action that screen reader users should be notified about (e.g., "Copied"). Use live="assertive" only for urgent status updates. The morphing animation is visual only; the final string is announced by the live region after the transition completes. When prefers-reduced-motion: reduce is set, the component skips the character-by-character morph via useReducedMotion() and renders the text directly — no extra configuration needed.

Credits

Inspired by Torph. Reimplemented for React and Web Animations API.

Built by Axyl. A motion-first component registry for React.

Last updated: 10/28/2026

On this page

Help keep SoraLabs moving.

Every contribution helps us build and maintain open-source tools for the community.

Sponsor on GitHub