# Letter Flip Hover

> A link or button whose letters roll up on hover, each replaced by a copy from below, one after another. Pure CSS.

Category: Text · Free · Updated 2026-11-14 · Live demo: https://www.motionkitui.com/components/letter-flip-hover

## When to use it

Navigation links, footer links, buttons and calls to action across agency, portfolio and product sites.

## How it works

Each letter sits in a clipped box with an identical copy directly below it. On hover or keyboard focus, both copies slide up by their own height with a CSS transition, each letter delayed a little more than the one before. It's all CSS, so nothing runs until you hover.

## Installation

```bash
npx shadcn@latest add https://www.motionkitui.com/r/letter-flip-hover.json
```

Or copy `components/motionkit/letter-flip-hover.tsx` below. Requires react and Tailwind CSS v4. Free for personal projects; commercial use needs MotionKit Plus (https://www.motionkitui.com/pricing).

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` | `string` | `"Get in touch"` | The label, as plain text. |
| `href` | `string` |  | Makes it a link; without it, it's a button. |
| `onClick` | `() => void` |  | Click handler. |
| `stagger` | `number` | `22` | Milliseconds between letters. |
| `duration` | `number` | `420` | Milliseconds each letter takes. |
| `hoverColor` | `string` |  | Colour of the letters that roll in. |
| `after` | `ReactNode` |  | Shown after the label, such as an arrow icon. |

## Accessibility

- **Keyboard: Pass.** A real link or button; the roll also plays on keyboard focus, with a visible focus ring.
- **Screen readers: Pass.** The label is read once from a hidden copy; the rolling letters are hidden.
- **Reduced motion: Pass.** With reduced motion on, letters don't move; the hover colour changes instead.
- **Colour contrast: Pass.** Inherits your text colour; choose a hover colour that also meets 4.5:1 on your background.

## Source

```tsx
"use client";

import type { CSSProperties, ReactNode } from "react";

type LetterFlipHoverProps = {
  /** The label. Plain text only, since each letter is animated. */
  children?: string;
  /** Makes it a link; without it, it's a button. */
  href?: string;
  onClick?: () => void;
  /** Milliseconds between one letter and the next. */
  stagger?: number;
  /** Milliseconds each letter takes to roll. */
  duration?: number;
  /** Colour of the letters that roll in. Leave unset to keep the same colour. */
  hoverColor?: string;
  /** Content shown after the text, such as an arrow icon. */
  after?: ReactNode;
  className?: string;
};

/**
 * A link or button whose label rolls on hover: each letter slides up out of view while an identical copy rises
 * from below, one letter after another, left to right. Pure CSS, so it costs nothing at rest. It also plays on
 * keyboard focus, screen readers hear the label once, and with reduced motion it simply changes colour.
 */
export function LetterFlipHover({ children = "Get in touch", href, onClick, stagger = 22, duration = 420, hoverColor, after, className = "" }: LetterFlipHoverProps) {
  const letters = [...children];
  const style = { "--flip-duration": `${duration}ms`, "--flip-color": hoverColor ?? "currentColor" } as CSSProperties;
  const body = (
    <>
      <span className="sr-only">{children}</span>
      <span aria-hidden className="inline-flex overflow-hidden whitespace-pre leading-[1.15]">
        {letters.map((letter, index) => (
          <span key={index} className="relative inline-block">
            <span
              className="inline-block transition-transform ease-[cubic-bezier(0.16,1,0.3,1)] [transition-duration:var(--flip-duration)] group-hover:-translate-y-full group-focus-visible:-translate-y-full motion-reduce:transition-none motion-reduce:group-hover:translate-y-0"
              style={{ transitionDelay: `${index * stagger}ms` }}
            >
              {letter}
            </span>
            <span
              className="absolute left-0 top-full inline-block text-[var(--flip-color)] transition-transform ease-[cubic-bezier(0.16,1,0.3,1)] [transition-duration:var(--flip-duration)] group-hover:-translate-y-full group-focus-visible:-translate-y-full motion-reduce:hidden"
              style={{ transitionDelay: `${index * stagger}ms` }}
            >
              {letter}
            </span>
          </span>
        ))}
      </span>
      {after}
    </>
  );
  const classes = `group inline-flex items-center gap-2 font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-[#B9C7FF] focus-visible:ring-offset-4 focus-visible:ring-offset-[#0C1010] motion-reduce:hover:text-[var(--flip-color)] ${className}`;
  return href ? (
    <a href={href} className={classes} style={style} onClick={onClick}>
      {body}
    </a>
  ) : (
    <button type="button" className={classes} style={style} onClick={onClick}>
      {body}
    </button>
  );
}
```
