Text morph
Text that changes the way it should: shared letters slide over, new ones rise out of a blur, the width eases.
Used forButton labelsHero headlinesStatus labelsPlan names and billing lines
Install with the shadcn CLI
Registered the namespace? Then it’s shadcn add @hairline/text-morph. Set it up
Templates
Need the whole page?
63 Next.js landing pages, each designed from scratch. Try any of them live; one is $39, all of them $159, and 8 are free.
Where it’s used
Button labels
Save becomes Saving becomes Saved, without a hard swap.
Hero headlines
A rotating word in a headline that the sentence reflows around.
Status labels
Pills and badges that change their wording as things progress.
Plan names and billing lines
Any short text that changes when a setting changes.
What it handles for you
Most interfaces swap text in a single frame. This is the primitive that makes any label change feel considered, and many of the components in this library are built on it.
Shared letters stay
“Save” to “Saving” keeps “Sav” and glides it into place. Only “ing” is new.
New letters rise
They come up out of a soft blur, one after another.
Old letters lift away
Letters that leave fade where they stood.
The box resizes with it
The width eases, so the button or pill around it resizes in the same motion.
Unrelated words crossfade
When two texts share less than half their letters, they crossfade whole instead of flinging letters about.
Real text for readers
Screen readers and search get the real text, and interrupting a morph continues smoothly from where the letters are.
Overview
Most interfaces swap text in one frame: "Save" is simply replaced by "Saved". Here the letters both words share stay alive and slide to their new places, new letters rise in out of a soft blur one after another, and the ones that leave lift away where they stood. The box eases to its new width, so the button or pill around it resizes in the same motion. Words with little in common crossfade as a whole instead of flinging single letters across. Use it for any label that changes.
States
- shared letters
- "Save" → "Saving" keeps "Sav" and glides it; only "ing" is new.
- new letters
- Rise 0.35em out of a 4px blur, 16ms apart, easing out over 460ms.
- leaving letters
- Lift the other way and blur out where they stood, in 60% of the time.
- width
- The box eases from its old width to its new one, carrying its container with it.
- unrelated words
- With less than half their letters in common, the texts crossfade as a whole.
Usage
Works with
Built on it
- ReactionsEmoji reactions for comments and messages: press, slide along the tray and let go, and the emoji flies into its chip.
- Voice barA multimodal AI prompt and voice bar on a dither lattice: every word you say condenses out of the wave into the transcript, and the prompt grows line by line.
- Passkey buttonA biometric passkey button whose 9-ridge fingerprint scans optically ridge by ridge while pending, then sweeps an 8×8 Bayer wave across the pill as the ridges draw into a check.
- Page outlineA spring-guided hairline table of contents and collapsible reading progress pill whose active indicator glides smoothly along a continuous stepped SVG path.
- Voice orbVoice mode for your assistant: plasma in a glass globe that the voice moves, with the talk button, the microphone and the reply wired to your own backend.
- Spending ringWhere the money went, and what is inside it: thick tiles with their amounts on them, and a category that blooms open into a ring of its own.
- Threshold lineSet an alert by seeing what it would have done: drag a line across the last 30 days and every day over it turns red while the count of alerts rolls.
- Compare barsThis period, and with one press the one before: every bar splits in two, then what was gained turns green and what fell short shows in red.
- Share barParts of a whole as one bar that comes apart into a ranked list: each segment drops out and slides into its own row, keeping its width.
- Dot meterSeveral goals at once, each a small field of dots that pours in like grains: protein, carbs and fat, or seats, storage and API calls.
- Liquid logThe card is the vessel you log into: tap + and a drop falls into a live surface, the ripple runs to the walls, then the level rises.
- Tour lineA product tour drawn with one hairline frame: it draws itself round the first thing you’re shown, then glides and reshapes itself onto each next one, the card riding along.
- Streak chain“Don’t break the chain”, drawn big enough to care: today’s ring hangs open until you complete it, then it closes, fills with colour and the chain grows a ring.
- Signature padSign with ink that behaves like ink: it thickens where you slow down, dries in the order you wrote it, and clearing rewinds your strokes.
- Token bucketA rate limit you can watch refill: tokens grow at the real rate, requests take them, and waiting requests are carried off as each new one forms.
- Time overlapFind a meeting time across time zones: each person’s day in hairline marks, a band you drag across everyone, and it settles into the hours you all share.
- Goal tapeHow far to free shipping, and the moment you get there: the fill runs into a satin ribbon stretched across the bar at the goal and bows it until it snaps.
- Merge buttonMerge a pull request and see it go in: the button carries a small branch graph, and pressing it draws what your merge strategy really does to main.
- Status capsuleA pill for something that takes a moment: a ring turns while it runs, and when it’s done a ribbon of light scans the pill and the words change under it.
- Hold to startA card whose main action is held: light gathers toward your finger while you hold, and bursts across the card when it starts.
- Scene mixerA few levels and the scenes that set them: press a scene and a soft veil of light drifts across the card while every level glides to its place.
- Pillar chartA period of activity as glass pillars on dark lacquer: point at one and it turns white, switch the range and the new pillars rise in a wave.
- Stage timelineA session as stages over time on dark lacquer, with a dot-matrix clock that turns to the time under your finger as you scrub.
- Track playerA small lacquered player: the disc turns, the waveform ripples and fills as it plays, and changing track drifts a veil of light across it.
- ButtonThe base action: variants, 24–40px sizes, a 3% press, and status (pending, success, error) shown through an icon slot and a morphing label.
- Copy buttonCopies on the press: the icon blurs into a self-drawing check, the label morphs to Copied, and a failed copy shakes and says so.
- Action buttonA button that runs a promise and shows it: the icon slot opens for a spinner, a check draws itself, failures shake, and the label morphs through each.
- Expanding button groupIcon toolbar where the action you point at, tab to or tap opens its label while neighbours slide aside, with ask-first and done states in place.
- Password inputA password field with an eye that turns into eye-off, a four-step strength meter that fills and names itself, and a Caps Lock warning.
- SelectA choice from a list that is never the browser's dropdown: the pill grows into its list and folds back as the label morphs.
- Multi-selectSeveral choices from a short list: the pill names them ("Design, Sales +2"), the list rises off it with ticks that draw, and it stays open while you pick.
- Date pickerOne date, typed or picked: the field reads "tomorrow", "next fri" or "4 nov", and the calendar slides by month while one mark glides between days.
- Time pickerType “9:30 pm” or fling the hour, minute and AM/PM drums; both paths settle into one plain HH:mm value.
- Timezone pickerA searchable IANA timezone picker with live local clocks, exact UTC offset deltas, a spring-driven 24-hour daylight hairline and one-click Detect.
- Color pickerA colour field with a real saturation surface, kinetic hue and opacity rails, typed hex, RGB or HSL, and swatches that stay in sync.
- Currency inputA locale-aware money field with caret-safe typing, currency formatting, keyboard steps and clean numeric values for your backend.
- Phone inputAn international hairline phone input with searchable calling codes, caret-safe national formatting, automatic +E.164 country detection and structured output.
- Credit card inputA single-line hairline card composer with live Visa, Mastercard, Amex and Discover detection, 3D CVC back-stripe flip, Luhn validation and seamless field handoff.
- Rating inputWhole or half-star ratings with hover previews, rolling values and native radio behaviour for keyboards, forms and screen readers.
- BadgeA status, a tag or a count: statuses ease their colour and morph their word, live dots breathe, counts roll and fold away at zero.
- ProgressHow far along, as a bar or a ring: the fill eases to each value, the percent rolls, and at 100 it turns green and a check draws itself.
- Empty stateWhat a list says before there is anything in it: an isometric line drawing in your theme that draws itself, changes with the state and acts out the action.
- Shortcut sheetA searchable keyboard shortcuts reference and modal with live physical keycap lighting, chord and sequence matching and OS-aware glyphs.
- Collapsible"Show 4 more" that opens in place: the hidden part eases open through a blur while the button's words morph to "Show less".
- StepsWhere you are in a flow: the line to the next step fills along its length, the finished number blurs into a drawn check, and phones get "Step 2 of 4".
- Status buttonSave, Saving, Saved: the spinner opens in, the check draws itself, errors shake, and the label morphs between them.
- Waitlist fieldAn email field that becomes its own answer: the button stretches across it, then settles as "You’re on the list · #1,248".
- Code inputThe six boxes, done properly: digits rise in, a paste cascades, a wrong code shakes and clears, the right one becomes a pill with a check.
- Steps formA multi-step form in one card that changes shape: steps slide in from the way you’re going, checks shake and explain, and Create turns into what comes next.
- Date range pickerA range is one liquid band: it follows your pointer between days, presets flow it to their span, and the dates morph as it moves.
- TestimonialsOne quote, chosen by its people: faces step forward, the words cross-fade through a blur, a ring keeps time.
- Expanding galleryAn image opens from its exact place in the grid, becomes a spacious viewer, and finds its way back.
- Workflow canvasConnected steps you can move, inspect and follow as work flows through them.
- Image compareTwo images, one precise divide. Drag to reveal what changed, then let the handle settle.
- Magnifying dockA dock that makes room for the tool you reach for, then opens it in place.
- Hold to confirmA deliberate action, held for a moment: the ring fills, the label changes, and confirmation settles into a check.
- Drop zoneA considered file uploader. Clear actions, quiet progress and useful feedback.
- Drop zone · MembraneA drop zone whose border is a membrane: it reaches for the file, holds it, swallows it and passes it through to its row.
- Wheel pickerDrums you can fling: each column is a real cylinder that decays onto a row, with a lens in full colour over the middle.
- Morphing chartBars, line and area as one set of marks: bars condense into beads, a thread is strung through them, the fill pours down. Drag the switch to scrub it.
- Tag inputThe invite field, done properly: typed letters grow a chip round themselves, pasted lists spill out of the caret, and a duplicate flies into its twin.
- Avatar cropperThe profile photo field without a modal: the avatar itself grows into the crop, and shrinks back with the face you framed.
- Week calendarA scheduling week you hold in the hand: drag a slot into an event while its times roll, and anything it lands on eases aside.
- Inline editRename a title, a project or a row where it stands: the text becomes the field without moving a pixel, and saves itself.
- ComboboxPick one or several from a list your server searches: results morph between queries instead of flashing, and picks fly into chips.
- Cron inputA schedule field people can read: cron or plain English in, the meaning in words and the next runs out, with clock changes flagged.
- Time range picker"Last 15 minutes" for logs, metrics and traces: type 2h or yesterday 14:00–16:00, step by the window, pause live, or drag across a chart to zoom.
- Weekly hoursA recurring Mon to Sun operating and availability hours editor with split shifts, aligned 24-hour coverage bars, overlap guards and Copy to Mon-Fri.
- JSON inspectorRead, search and quote a webhook payload or an API response, or see exactly what changed between two versions of a record.
- Data tableA table whose rows travel: sort and every row glides to its rank, live data re-ranks itself, and selection turns the toolbar into its actions.
- Kanban boardA pipeline you rearrange by hand: the card becomes the stage it's over while still in the air, and every column's total rolls as it passes.
- Filter barThe bar above a list, done like Linear’s: one panel from property to value, chips you change in place, and a sentence that becomes filters.
- API keysThe API keys screen, done properly: the secret rises in once, and Done folds it down into the "sk_live_••••4f2a" it leaves behind.
- Env editorA structured .env and secrets editor with multi-line .env bulk paste, automatic 8×8 Bayer secret veiling, copy-while-veiled, duplicate key checks and Prod/Prev/Dev scopes.
- Backup codesA 2FA recovery codes panel with 1.5px 8×8 Bayer secret veiling, copy-while-veiled, .txt export, used-code audit stamps and inline regeneration.
- IP allowlistA CIDR and firewall allowlist editor with IPv4/IPv6 validation, live subnet host counts, wildcard exposure guards, containment checks and bulk paste.
- Team membersSettings → Members, done properly: invited addresses fly out of the field onto their rows, role pills grow into the list of roles, and seats roll.
- Settings formA settings page that saves the way people expect: switches save themselves, text edits gather into one bar that rises with "2 unsaved changes".
- Auth cardSign-in that asks one thing at a time: the email field shrinks into a chip round the address, and your server decides whether a password, a code or a link comes next.
- Sudo gateWrap any dangerous button. A padlock on its corner shows how long you stay verified; when it’s locked, the button grows right where it stands into the “Confirm it’s you” card.
- WebhooksSettings → Webhooks, done properly: "Send test" runs a bead down the wire to the endpoint and back in the answer's colour, and every delivery opens into its request and response.
- Domain connectA custom domain from typed to live: copyable records that tick green as DNS finds them, checks that wait longer each time, and a rail that runs to Live.
- Log streamA live tail you can actually read: scroll up and it lets go while a "↓ 128 new" pill counts what arrives, with pause, level counts, search and lines that open into their fields.
- Job queueA worker pool’s jobs grouped by what needs you: reviews first, each job’s status ring doubling as its clock, approvals and retries that call your server.
- CSV importContacts → Import, done properly: your file's columns thread themselves to your fields, bad cells become fields you fix in place, and the rows go to your server in batches.
- Notification inboxThe bell, done properly: its own circle grows into the inbox, new notifications swing it and roll the count, and read ones fold out of Unread.
- IntegrationsSettings → Integrations, done properly: Connect waits on the provider's own window, then folds away as the account it connected opens in its place.
- Status barsA status page that reads at a glance: ninety days a service drawn up bar by bar, one card that glides between them, and incidents whose updates open in as they're posted.
- Command palette⌘K that grows out of the search pill: fuzzy search, nested lists, and commands that run in place.
- Toast stackNotifications with continuous squircle geometry that stack, fan out on hover, follow a promise in one toast, and swipe away.
- Live activityOne pill for whatever is happening now: it updates in place, tap it and it grows into a panel, done blurs into a check.
- Live mapThe world as dots, lighting up where things happen: pings ripple, the light lingers, and one card follows the newest event from city to city.
- Theme toggleThe sun sets into a moon, and the new theme spreads from the button in a circle.
- Pricing calculatorDrag to your size and watch the price roll, the plan morph and, at the top, “Let’s talk”.
- Onboarding checklistThe first five things, ticked off in place: a ring that fills, checks that draw, and a finish worth seeing.
- Changelog timelineWhat shipped, drawn as you read: a rail that fills, dots that light, filters that fold the rest away.
- Changelog traceWhat shipped, routed like a circuit: the line steps aside between releases, and a bead runs down it as you read.
- Changelog scrubberYour release history on a ruler you scrub: drag the playhead, or press play and watch the product ship.
- Cookie bannerAsks once, plainly, then folds into a small cookie button in the corner that grows back into the preferences.
- Newsletter footerA footer that’s still alive: a signup that becomes its own confirmation, drawn link underlines and your name in outline.
- Agent composerThe taller composer for agent surfaces: branch, folder and context on a tab above, permissions and model as pills that grow into their lists.
- Mentions and commandsType @ to pull in context or / for a command. The menu grows from the caret and your text becomes a chip.
- Attachment chipA file on its way into a prompt: uploading, being read, ready or failed.
- Mode switcherFast, Thinking, Research: a segmented switch with a sliding pill and locked paid modes.
- Model pickerThe model pill in your composer grows into the menu: what each model is for, speed, smarts and thinking effort.
- Voice inputDictate a prompt: a waveform from your real mic level, a timer, then transcribing.
- Thinking indicatorFour quiet loaders for the gap before the first token, with a label, a rolling timer and a finish that draws itself.
- Thinking traceAn expandable record of what an agent did: steps, reasoning, search or tool calls.
- Tool callOne tool invocation from arguments to result: preparing, running, done, failed or denied.
- Clarifying questionThe agent pauses to ask. Pick with a click or a number key, or type your own; it folds into a one-line receipt.
- Approval cardThe agent asks before it acts: what it wants to do, the details, Approve or Deny.
- Web researchWatch the agent search: the query types in, page icons stack up as it reads, then it folds into a trail of searches and the pages each one found.
- Command outputA command the agent runs: the log streams in, folds away on success, and stays open on failure.
- Task progressFor work that takes minutes: phases, a live timer, stats, cancel, and the result when it’s done.
- Task logWhat the agent did, task by task, as it does it: steps arrive on a hairline trail, files sit in chips, titles turn past tense.
- Code blockCode in an answer: highlighted as it streams, copy and wrap, long files folded, and an optional Apply.
- Inline rewriteDrag a dial and the paragraph rewrites itself in place: shared words glide, the rest blur out and rise in.
- Diff reviewAccept or reject what the AI changed, word by word for prose or line by line for code.
- Action receiptsWhat the agent actually did, one quiet line each, with Undo while a ring drains. Several stack into one.
- Error and limit statesCalm, specific notices for failed answers, being offline, rate limits and chats that grow too long.
- Usage meterCredits, messages or context left: quiet when there’s plenty, clear before it runs out.
- Jump to latestA chat that follows the answer as it streams, lets go the moment you scroll up, and brings you back.
- Earnings chartA bar chart that changes instead of redrawing: bars glide between periods, the scale and the total roll, a readout follows the pointer.
- Steps chartA week against a daily goal: days that make it fill in, a wave runs the way you step through the weeks, the totals roll.
- Revenue chartThis year as an area, last year behind it; point at a month and the header becomes the readout, switch the measure and the lines reshape.
- Area chartSeveral series stacked, overlapping or as shares: every band morphs between layouts, and the tiles are the legend, the switches and the readout.
- Trend chartOne metric over time, the way an analytics screen needs it: the period before as a dashed line, an unfinished day drawn dashed, a readout that glides with the pointer, and drag to zoom.
- Combo chartEvery day as a bar and the trend as a line on one scale: point at a day and the header becomes its readout while the line’s dot pings where it lands.
- Activity ringsThree daily goals as concentric rings beside a tight legend, with the week underneath: pick a day and the rings sweep to it.
- Donut chartParts of a whole as a ring or a half-ring gauge: point at a slice and the centre rolls to it, hide one and the rest slide round.
- Activity heatmapEvery day as a square, weeks across: one readout glides to the day you point at, and new numbers ripple through week by week.
- Live line chartOne metric as it happens: each point slides in at an even pace, the scale eases, and a Live pill pauses the view.
- WalletA balance you can send from: the balance panel turns into the transfer, the button goes Sending → Sent, and the money visibly leaves.
- ConvertA two-sided exchange block joined by a live rate hairline that shortens from both ends as the quote ages, re-quotes in place with delta and snaps taut on lock.
- Pricing plansPlans that turn into their own checkout: pick one and its card becomes the order, seats and totals rolling, then Continue opens your checkout.
- BookingBook a call on one card: the time you pick prints onto the host’s ticket, then the times turn into your details and the confirmation.
- CartA cart whose receipt does the maths in front of you: codes are stamped on, a rail of light fills toward free shipping and every total rolls.
- ReferralA referral pass that fills as friends join: their faces fly up into its notches, and the last one turns the track into Claim.
- FeedbackA score that changes the question: pick 0–10 or stars, the score rolls into the panel, and the follow-up and its tags fit what you picked.
- Buy boxA product buy box whose swatches repaint the product: pick a colour and size, and Add to bag throws the product into the bag.
- CheckoutA one-page checkout whose steps stack into a receipt: contact, address, delivery and your payment element, then Place order turns into the order number.
- Order statusAn order’s route with a parcel riding it: stops light as it passes, the arrival day rolls, and the carrier’s scans slide in.
- SubscriptionA billing page in one card: the plan with a ring through its billing period, usage, card and invoices, and a cancel that offers a pause first.
- File shareDrop files, watch them upload, and they fold into one share link with an expiry and an optional password.
- PollA poll whose bars race to their share: vote, and every option fills with light while the percentages roll and live votes keep nudging them.
- Cookie consentA cookie banner with a mascot: every cookie you allow flies to Crumb, who catches it, nibbles it and gets rounder and happier.
- Create passwordA password step with a chameleon: the stronger the password, the better Hide blends in, until only his eye is left.
- Verify codeA one-time code step with a carrier pigeon: Coo naps through the resend wait with the seconds in a thought bubble, and flies every new code to your mailbox.
- Delete workspaceA danger-zone delete with a ghost: as you type the name, Boo climbs out of the workspace’s tile, and holding Delete waves him off the stage.
- Not foundA 404 with a search and a puppy: Fetch sniffs as you type, sprints off to fetch the results and comes back with a newspaper, or a stick.
- WaitlistA waitlist that is an actual line: you step in at the end with your number over your head, and every friend who joins lets you hop past the person ahead.
- StorageA storage meter with a raccoon and his suitcase: near the limit the case bulges and Pack sits on it to shut it; clean up and he hops down, upgrade and a roomy trunk arrives.
- UsernameA username picker with a penguin holding a sign: your name appears on it as you type; if it’s taken, its smug owner slides in hugging a sign with your name on it.
- Task cardTasks on a textured tray in your colours: tick one and a line travels slowly through its name, the ink fading behind it, then done tasks glide below the open ones.
- Seat mapPick seats while other people are picking too: yours rise with your initials, and a seat taken under you turns over with a ripple and points to the next best.
- LeaderboardWhere you stand and what it takes to move up: a line that fills as you close on the person above, and an overtake that swings out a lane to pass.
- Halftone heroA monumental 3D WebGL halftone-engraved hero framed by a dense 4-band hairline grid, optical clarity pointer lens, velocity-braking logo rail and interactive 3D capability switcher.
In a headline
Morph one word inside a sentence; the sentence reflows around it smoothly.
Props
- children
- string
- The text. Change it and it morphs.
- duration= 460
- number
- Morph time in ms.
- direction= "up"
- "up" | "down"
- New letters rise from below ("up") or drop from above ("down").
- animateWidth= true
- boolean
- Ease the width; turn off for text that wraps over several lines.
Accessibility and motion
- The real text is in the page for screen readers and search; the moving letters are hidden from assistive tech.
- Words never break mid-word: letters are grouped by word, so lines only wrap at spaces. While the width eases, the words hold to one line, so "Credits left" never wraps halfway into "No credits left".
- Uses the Web Animations API, with no animation library. Interrupting a morph mid-flight continues smoothly from where the letters are.
- With reduced motion the text changes in place.
Requirements
React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.
Source
Registry item: /r/text-morph.json


