Overview
Split Text Button splits its label into characters, each a tiny clipped column holding the glyph and an accent-coloured duplicate. On hover or keyboard focus the columns slide in sequence, so the word appears to roll over. Direction, stagger order, per-character duration and easing are all configurable, and the whole effect is plain CSS transitions — no animation library and no JavaScript on hover.
01Installation
Method 01 · Registry
CLI verifiedUses the shadcn CLI in a project initialised with shadcn init. Installs the file to components/ui/split-text-button.tsx and adds its dependencies.
npx shadcn@latest add https://wancraft.my/r/split-text-button.jsonMethod 02 · Copy and paste
- 1. No extra dependencies — React and Tailwind CSS only.
- 2. Copy the source from the Code tab into
components/ui/split-text-button.tsx. - 3. Import it and adjust props.
- Dependencies
- None
- Peer
- react ≥ 18, tailwindcss ≥ 4
- Added
- 1 Oct 2026
- Updated
- —
02Usage
The default configuration. Change properties above to generate a tailored example in the Usage tab.
import { SplitTextButton } from "@/components/ui/split-text-button";
export function SplitTextButtonExample() {
return (
<SplitTextButton>
View the work
</SplitTextButton>
);
}03Props
| Prop | Type | Default | Description |
|---|---|---|---|
| children | string | — | Plain-text label. Rendered once as screen-reader text and once as aria-hidden characters. |
| direction | "up" | "down" | "up" | Direction the characters travel. |
| stagger | number | 24 | Delay between characters in ms. |
| duration | number | 450 | Per-character transition duration in ms. |
| easing | string | "cubic-bezier(0.16, 1, 0.3, 1)" | Any CSS timing function. |
| staggerFrom | "start" | "center" | "end" | "start" | Which end of the label moves first. |
| accent | string | "#FF7448" | Colour of the incoming line, ghost underline and focus ring. |
| variant | "ink" | "outline" | "ghost" | "ink" | Visual style. |
| ...props | ButtonHTMLAttributes | — | Native button attributes are forwarded; the ref points to the <button>. |
04Features
- 01Per-character roll with configurable direction, stagger order and easing
- 02Same effect on hover and keyboard focus-visible
- 03Pure CSS transitions — zero runtime dependencies
- 04Hover styles only apply on devices that can hover
05Accessibility
- Native <button>; the accessible name is the plain label from a visually hidden span.
- The split characters and their duplicates are aria-hidden, so screen readers never read letters one by one.
- Keyboard focus triggers the same transition and shows an accent focus ring.
- With prefers-reduced-motion the characters swap instantly instead of sliding.
06Limitations
- The label must be a plain string; rich children cannot be split per character.