Text States

Overview

A status label that swaps its text in place, exiting up with blur and entering from below.

This feedback component is intended for interfaces that need a status label that swaps its text in place, exiting up with blur and entering from below, form workflows, and support tools. Its implementation is provided as editable source so the final behavior and styling stay inside your project.

Technologies

React
TypeScript
Tailwind CSS

No additional package dependency is declared for this component.

@spectrumui/text-states

Click — the label exits up with blur and the next state enters from below.

Installation

Login to view commandCreate a free account to access the install command

Usage

import { TextStates } from "@/components/spectrumui/text-states"
<button onClick={save}>
  <TextStates text={saving ? "Saving…" : saved ? "Saved" : "Save"} />
</button>

API Reference

TextStates

The Text states swap recipe from transitions.dev (Jakub Antalík), embedded as its namespaced t-text-swap CSS with the reduced-motion guard intact. The component runs the recipe's three-phase class sequence every time the text prop changes, so it drops into any button or status line.

PropTypeDefaultDescription
*textstring-Current text; each change runs the exit and enter swap
durationnumber150Swap duration in ms per phase
translateYnumber4Travel distance in px
blurnumber2Blur amount in px
classNamestring-Classes for the span

Use cases

  • interfaces that need a status label that swaps its text in place, exiting up with blur and entering from below
  • form workflows
  • support tools

Features

  • Copy-paste source that remains in your repository
  • TypeScript source included with the component
  • Tailwind CSS classes editable in the component source
  • Reduced-motion handling present in the source

Accessibility

  • The source includes ARIA attributes or roles; preserve them when customizing the component.
  • The source checks reduced-motion preferences or includes motion-reduce styles.
  • Test focus order, keyboard operation, labels, contrast, and screen-reader output in the final application context.

Customization

  • Edit the Tailwind utility classes in the copied source to match your spacing, color, and typography tokens.
  • Use the documented className surface for local layout adjustments, then edit the source for structural changes.

Text States FAQ

Is Text States free to use in commercial projects?

Yes. The public Text States source is available under the Apache License 2.0, including for commercial use, subject to the LICENSE terms.

How do I install Text States?

Run npx shadcn@latest add @spectrumui/text-states. The page also exposes the source for manual installation.

Does Text States require Motion?

No Motion dependency was detected in the documented source or registry entry for Text States.

Does Text States use shadcn/ui or Radix UI?

No shadcn/ui or Radix UI dependency was detected in the documented Text States source.

Can I use Text States in Next.js?

The documented React source is used in this Next.js application. Keep its use client directive when copying it into the App Router. Install the detected dependencies and verify any application-specific data or image configuration.

What accessibility checks should I run for Text States?

The source includes ARIA markup, reduced-motion handling. Test the finished interface with keyboard and screen-reader workflows.

Work with me