---
title: "Text Shatter"
description: "A press cracks the text into glass shards that fly, fall, and bounce, then come back together into letters."
url: https://gelatinui.com/components/text-shatter
markdown_url: https://gelatinui.com/components/text-shatter.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/text-shatter"
version: "2026-11-15"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Text Shatter

> A press cracks the text into glass shards that fly, fall, and bounce, then come back together into letters.

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

## When to use it

Best for: One short, large word or heading that people press for fun and that must read clean again.

- Use it on display text, 20px and up. Each letter cracks into 3 shards at 20px and 6 from 56px.
- Use `trigger` for what breaks it: `click` (default), `view` or `mount` once, or `hover`.
- Set `shatter` to hold the shards apart from app state; false brings them home.

## When not to use it

- For words that fall into a box and stay in a pile, use [Text Falling](https://gelatinui.com/components/text-falling.md).
- For letters people drag and stretch, use [Text Elastic Letters](https://gelatinui.com/components/text-elastic-letters.md).

## Notes for agents

- `children` is a string, or the parts `TextShatterContent` and `TextShatterCanvas`. Leave out the canvas part for plain text.
- The real text stays in the page: wrap, selection, and the accessible name do not change. The canvas is `aria-hidden`.
- With `trigger="click"` the root is a button with the text as its name, and one tab stop.
- Matter.js (about 26 KB gzip) loads on the first hover, focus, or press. With no 2D canvas or no Matter.js, the text stays plain; `onError` gets a load error.
- Over 40 letters, and in Arabic and other joined scripts, each word cracks as one piece.
- The loop stops when every letter is home, and waits off screen. A resize mid-flight puts the text back at once.

## Anatomy

```text
TextShatter
├─ TextShatterContent (0..n)
└─ TextShatterCanvas (0..n)
```

## API reference

### TextShatter

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` | `ReactNode` |  | A string, or the parts `TextShatterContent` and `TextShatterCanvas`. |
| `onError` | `ReactEventHandler` |  | Called when Matter.js does not load (the text then stays plain). |
| `locale` | `string` |  | The BCP 47 locale of the text, for the letter split and the case of `text-transform` on the canvas. Default: the `DisplayLocaleProvider` locale, else `"en-US"`. |
| `trigger` | `"click" \| "hover" \| "mount" \| "view"` | "click" | What shatters it: `click` (default) a click or tap, or Enter or Space when it has focus; `view` once, the first time it shows; `mount` once, at once; `hover` each time a pointer or keyboard focus reaches it (or the link around it). |
| `shatter` | `boolean` |  | True shatters it and holds the shards apart until false; then they come home. |
| `onSettled` | `function` |  | Called when every letter is home and the page text shows again. |

### TextShatterContent

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### TextShatterCanvas

No props of its own: `className`, `children`, and every other prop go to the element it renders.

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| TextShatter | `text-shatter` |  |  |  |
| TextShatterContent | `text-shatter-content` | `data-shattering` |  |  |
| TextShatterCanvas | `text-shatter-canvas` | `data-shattering` |  |  |

## Usage

Wrap the word people can break. It is a button for the keyboard, inside the heading.

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-pro/text-shatter @gelatin-ui/button
```

```tsx title="landing-hero.tsx"
import { TextShatter, TextShatterCanvas, TextShatterContent } from "@/components/pro/text/text-shatter";
import { Button } from "@/components/ui/button";

export function LandingHero() {
  return (
    <section className="flex flex-col items-center gap-6 py-24 text-center">
      <h1 className="text-6xl font-bold tracking-tight">
        <TextShatter>
          <TextShatterContent>Break</TextShatterContent>
          <TextShatterCanvas />
        </TextShatter>{" "}
        things. They come back whole.
      </h1>
      <p className="max-w-md text-lg text-muted-foreground">
        Press the word, or Tab to it and press Enter.
      </p>
      <div className="flex gap-3">
        <Button size="lg">Browse components</Button>
        <Button size="lg" variant="outline">
          Read the docs
        </Button>
      </div>
    </section>
  );
}
```

## 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-pro/text-shatter
```

It adds 35 registry items: 35 files, 4812 lines, and the npm packages `@mantine/hooks`, `@xstate/react`, `clsx`, `matter-js`, `motion`, `tailwind-merge`, `xstate`.

## 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

- [Text Falling](https://gelatinui.com/components/text-falling.md)
- [Text Elastic Letters](https://gelatinui.com/components/text-elastic-letters.md)
- [Text Liquid](https://gelatinui.com/components/text-liquid.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Tab | Moves the focus to the text, with `trigger="click"`. |
| Enter, Space | Shatters the text. In flight, it throws the shards again. |

## Motion

| Part | Motion |
| --- | --- |
| Crack | press · 100ms · each shard moves out 0.03em, so hairline cracks show |
| Flight | drift · 0.9s · the shards burst out and up, tumble, and bounce on Matter.js physics at 120 steps a second |
| Return | drift · spring · 476ms · each shard glides home at 15px per frame at most, and each letter locks whole |
