---
title: "Text Perspective"
description: "Lines of text sit at different depths on a 3D plane that tilts with the scroll or the mouse and goes flat mid view."
url: https://gelatinui.com/components/text-perspective
markdown_url: https://gelatinui.com/components/text-perspective.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/text-perspective"
version: "2026-11-14"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Text Perspective

> Lines of text sit at different depths on a 3D plane that tilts with the scroll or the mouse and goes flat mid view.

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

## When to use it

Best for: A statement of two to five short lines between two sections, flat in the middle of the view.

- Wrap the text of a heading. Every element is a `span`, so it is valid in an `h1` or `h2`.
- Use `by="line"` (default) and put a line break (`\n`) between the lines, or `by="word"` to give each word its own depth.
- Use `driver="scroll"` (default) to turn the plane with the scroll place, `pointer` to turn it away from the mouse, or `still` for a fixed pose.
- Use `angle` (default 20), `depth` (in em, default 0.6), and `perspective` (default 900px) to tune the look.
- Use `settle={false}` to keep the depth while it scrolls, `offset` to change the scroll range, and `container` when the text scrolls inside a box.

## When not to use it

- For a title folded like paper that unfolds as it scrolls in, use [Text Fold](https://gelatinui.com/components/text-fold.md).
- For a card or an image that turns toward the mouse, use [Tilt](https://gelatinui.com/components/tilt.md).
- For layers that move at their own speed as the page scrolls, use [Parallax](https://gelatinui.com/components/parallax.md).
- For body text or a long paragraph that people must read, use plain text.

## Notes for agents

- `children` must be a string. The lines or words are boxes, so the root carries the text as its name, with each line break as a space; an `aria-label` prop wins.
- The first piece is the nearest and the last is the farthest; depth is in `em`, so it grows with the font size.
- With `scroll`, the plane turns from `angle` when the text enters at the bottom to `-angle` when it leaves at the top, and is flat at the middle. No spring: the text is where the scroll puts it, and React does not render while the page scrolls.
- `pointer` runs with a mouse, a pen, or a finger while it is down, on a 150ms tween to each place; the lift brings back the rest pose.
- In a right-to-left text the rest pose turns the other way, so the far words go back from the first one and the spaces stay open.
- A value of `angle`, `depth`, or `perspective` that is not a number takes the default. A word wider than the line breaks, so it does not scroll a phone page sideways.

## Anatomy

```text
TextPerspective
```

## API reference

### TextPerspective

| 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 text. With `by` `line`, a line break (`\n`) starts a new line. |
| `by` | `"line" \| "word"` | "line" | The pieces that stand at different depths: `line` (default) or `word`. |
| `driver` | `"pointer" \| "scroll" \| "still"` | "scroll" | What turns the plane: `scroll` (default) the scroll place of the text, `pointer` the mouse on the text, `still` nothing (a fixed pose). |
| `angle` | `number` | 20 | The largest turn of the plane in degrees. Default 20. |
| `depth` | `number` | 0.6 | The depth step from one piece to the next, in `em` of the text. Default 0.6. |
| `perspective` | `number` | 900 | The 3D view distance in px. Smaller is stronger. Default 900. |
| `settle` | `boolean` | true | With `driver` `scroll`: the pieces come together into a flat text at the middle of the scroll range, and spread in depth before and after it. Default true. Off, they keep their depth. |
| `offset` | `ParallaxOffset` | PARALLAX_FULL_PASS | With `driver` `scroll`: the scroll range, in Motion's offset words. Default `["start end", "end start"]`: from the moment the text enters at the bottom to the moment it leaves at the top. The text is flat at the middle. |
| `container` | `RefObject<HTMLElement \| null>` |  | With `driver` `scroll`: the scroll box, when the text scrolls inside one. |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| TextPerspective | `text-perspective` | `data-driver` | `--perspective-text-angle`, `--perspective-text-depth`, `--perspective-text-dir`, `--perspective-text-perspective` |  |

## Usage

Wrap a statement between two sections. Put a line break between the lines.

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-perspective @gelatin-ui/button
```

```tsx title="speed-section.tsx"
import { TextPerspective } from "@/components/pro/text/text-perspective";
import { Button } from "@/components/ui/button";

export function SpeedSection() {
  return (
    <section className="mx-auto flex max-w-3xl flex-col items-center gap-8 px-4 py-40 text-center">
      <p className="font-mono text-xs tracking-widest text-muted-foreground uppercase">
        Why it feels fast
      </p>
      <h2 className="text-5xl leading-tight font-bold tracking-tight">
        <TextPerspective angle={20} depth={0.6}>
          {"Every frame\non time.\nEvery screen\nin reach."}
        </TextPerspective>
      </h2>
      <p className="max-w-md text-muted-foreground">
        Each press answers within a frame, on every device people own.
      </p>
      <Button variant="outline">See the numbers</Button>
    </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-perspective
```

It adds 22 registry items: 21 files, 4210 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `clsx`, `motion`, `tailwind-merge`.

## 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 Fold](https://gelatinui.com/components/text-fold.md)
- [Tilt](https://gelatinui.com/components/tilt.md)
- [Parallax](https://gelatinui.com/components/parallax.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Tab | With `driver="pointer"`: while keyboard focus is on the link or button around the text, the plane turns as the mouse at the right edge would turn it. |

## Motion

| Part | Motion |
| --- | --- |
| Scroll turn | none · the plane turns and the pieces spread in depth as the page scrolls, in the same frame as the scroll, with no easing; flat at the middle of the range |
| Mouse turn | hover · 150ms · the plane turns away from the mouse, up to `angle` degrees |
| Keyboard lean | panel · 260ms · keyboard focus around the text turns the plane to the side |
