---
title: "Text Roll"
description: "A link or button label rolls on hover, press, or focus: a copy rolls up from below, letter by letter or as one."
url: https://gelatinui.com/components/text-roll
markdown_url: https://gelatinui.com/components/text-roll.md
access: free
install: "npx shadcn@latest add @gelatin-ui/text-roll"
registry_item: https://gelatinui.com/r/text-roll.json
version: "2026-11-14"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Text Roll

> A link or button label rolls on hover, press, or focus: a copy rolls up from below, letter by letter or as one.

Page: https://gelatinui.com/components/text-roll

## When to use it

Best for: The short label of a link or button that rolls to a copy of itself on hover, press, or Tab.

- Put it inside a link or a Button: it reads the hover, press, and focus of the nearest one.
- Use the default `letters` mode for a short label, and `mode="label"` for a long label or one that wraps.
- Set `--text-roll-color` on the root to give the copy that rolls in another color.

## When not to use it

- For a label that scrambles through random letters, use [Text Scramble](https://gelatinui.com/components/text-scramble.md).
- For a plain button with no motion on its label, use [Button](https://gelatinui.com/components/button.md).

## Notes for agents

- `children` must be a string. `mode` is `letters` (default) or `label`.
- The roll is pure CSS: no listener and no render, and it works before hydration. It reads `:hover` (only on a device that can hover), `:active`, and `:focus-visible` of the nearest `a`, `button`, or `[role=button]` around it, else of the label itself.
- On a touch screen the label rolls while the finger is down and rolls back on release, so no hover stays.
- Only transforms move, so the width of the label never changes and nothing around it moves.
- Each letter waits 20ms more than the letter before it, at most 10 steps, so a long label does not lag.
- Arabic and other joined scripts roll by word. Emoji and accented letters stay whole, and the copy of an emoji keeps its colors.
- In `letters` mode the root names the label in one piece (`aria-label`), so a screen reader does not spell it. An `aria-label` prop wins.

## Anatomy

```text
TextRoll
```

## API reference

### TextRoll

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `locale` | `string` |  | The BCP 47 locale for the letter and word split (`Intl.Segmenter`). Default: the `DisplayLocaleProvider` locale, else `"en-US"`. |
| `children` | `string` |  | The label. It rolls when the link or button around it is hovered, pressed, or has keyboard focus. |
| `mode` | `"label" \| "letters"` | "letters" | `letters` (default): each letter rolls up, one after another. `label`: the whole label slides up and out while its copy slides in from below, as one block (a label on two lines too). |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| TextRoll | `text-roll` | `data-stage-active`, `data-stage-focused`, `data-stage-hover` | `--text-roll-color`, `--text-roll-gap`, `--text-roll-index`, `--text-roll-pad` | `motion-timing` |

## Usage

Put it inside a link or a Button as its label. It rolls when the control is hovered, pressed, or focused.

The sample also uses `button`, which this add does not write. One command adds them with this item:

```bash
npx shadcn@latest add @gelatin-ui/text-roll @gelatin-ui/button
```

```tsx title="site-header.tsx"
import { ArrowRightIcon } from "@phosphor-icons/react/ssr";

import { TextRoll } from "@/components/text/text-roll";
import { Button } from "@/components/ui/button";

const LINKS = ["Components", "Blocks", "Pricing"];

export function SiteHeader() {
  return (
    <header className="flex items-center justify-between gap-4 border-b px-4 py-3">
      <nav aria-label="Main" className="flex gap-6 text-sm text-muted-foreground">
        {LINKS.map((link) => (
          <a key={link} href={`#${link.toLowerCase()}`} className="hover:text-foreground">
            <TextRoll>{link}</TextRoll>
          </a>
        ))}
      </nav>
      <Button size="sm">
        <TextRoll mode="label">Start free trial</TextRoll>
        <ArrowRightIcon data-icon="inline-end" />
      </Button>
    </header>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/text-roll
```

It adds 5 registry items: 4 files, 1490 lines, and the npm packages `tailwind-merge`, `tailwind-variants`.

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Button](https://gelatinui.com/components/button.md)
- [Magnetic](https://gelatinui.com/components/magnetic.md)
- [Text Scramble](https://gelatinui.com/components/text-scramble.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Tab | Moves the focus to the link or button around the label. The label rolls while it has keyboard focus. |

## Motion

| Part | Motion |
| --- | --- |
| Letters | panel · 260ms · ease-panel (0.2, 0.4, 0.2, 1) · each letter moves up one line plus a gap while its copy comes up from below, 20ms after the letter before it |
| Label | panel · 260ms · ease-panel (0.2, 0.4, 0.2, 1) · the whole label slides up and out while its copy slides in from below |
| Roll back | panel · 260ms · ease-panel (0.2, 0.4, 0.2, 1) · when the hover, press, or focus ends, the label rolls back from where it is, with no jump |
