Skip to content
WANCRAFT

A.04Buttons & Controls

Split Text Button

A button whose label rolls character by character on hover or focus, revealing a duplicate line.

ReactCSSTailwindbasic

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 verified

Uses 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.json

Method 02 · Copy and paste

  1. 1. No extra dependencies — React and Tailwind CSS only.
  2. 2. Copy the source from the Code tab into components/ui/split-text-button.tsx.
  3. 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.

example.tsx
import { SplitTextButton } from "@/components/ui/split-text-button";

export function SplitTextButtonExample() {
  return (
    <SplitTextButton>
      View the work
    </SplitTextButton>
  );
}

03Props

PropTypeDefaultDescription
childrenstring—Plain-text label. Rendered once as screen-reader text and once as aria-hidden characters.
direction"up" | "down""up"Direction the characters travel.
staggernumber24Delay between characters in ms.
durationnumber450Per-character transition duration in ms.
easingstring"cubic-bezier(0.16, 1, 0.3, 1)"Any CSS timing function.
staggerFrom"start" | "center" | "end""start"Which end of the label moves first.
accentstring"#FF7448"Colour of the incoming line, ghost underline and focus ring.
variant"ink" | "outline" | "ghost""ink"Visual style.
...propsButtonHTMLAttributes—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
motion · staggermotion · tweeninput · hoverinput · focus

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.