---
title: "Spoiler"
description: "Long content cut at a set height with a fade, and a Show more button that opens the rest."
url: https://gelatinui.com/components/spoiler
markdown_url: https://gelatinui.com/components/spoiler.md
access: free
install: "npx shadcn@latest add @gelatin-ui/spoiler"
registry_item: https://gelatinui.com/r/spoiler.json
version: "2026-11-08"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Spoiler

> Long content cut at a set height with a fade, and a Show more button that opens the rest.

Page: https://gelatinui.com/components/spoiler

## When to use it

Best for: Long content cut at a height, with a Show more button under a fade.

- Use `maxHeight` for the cap in px.
- Use `fade={false}` for a clean cut.
- Use `align` on the trigger for its place.

## When not to use it

- For a fold with its own title row, use a [Collapsible](https://gelatinui.com/components/collapsible.md).

## Notes for agents

- It is a height cap, not a line clamp, so it holds any content.
- The trigger shows only on overflow.
- A photo that loads late grows the content, and it measures again.
- `onOpenChange` can cancel a change with `eventDetails.cancel()`.

## Anatomy

```text
Spoiler
├─ SpoilerContent (0..n)
└─ SpoilerTrigger (0..n)
```

## API reference

### Spoiler

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `maxHeight` | `number` | 100 | The height in px that shows while closed. Content taller than this gets the control. Default 100. |
| `fade` | `boolean` | true | Fade the bottom edge of the closed content out with a mask. Default `true`. |

Also takes every prop of Base UI `Collapsible.Root`: https://base-ui.com/react/components/collapsible

### SpoilerContent

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### SpoilerTrigger

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `align` | `"center" \| "end" \| "start"` |  |  |
| `size` | `"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs"` | "sm" |  |
| `variant` | `"dashed" \| "default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "media" \| "outline" \| "secondary"` | "ghost" |  |
| `className` | `string` |  |  |
| `showLabel` | `ReactNode` | "Show more" | The label while closed. Default "Show more". Pass a translated string. |
| `hideLabel` | `ReactNode` | "Show less" | The label while open. Default "Show less": close to the width of "Show more", so the button, which keeps the width of the longer label, shows no gap before the chevron. |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| Spoiler | `spoiler` |  |  |  |
| SpoilerContent | `spoiler-content` | `data-ending-style`, `data-fade`, `data-overflowing`, `data-starting-style` | `--collapsible-panel-height`, `--spoiler-fade`, `--spoiler-fade-length`, `--spoiler-max-height` | `motion-timing` |
| SpoilerTrigger | `spoiler-trigger` | `data-disabled` |  | `motion-timing` |

## Usage

Put the content and the trigger in the root.

```tsx title="long-description.tsx"
import { Spoiler, SpoilerContent, SpoilerTrigger } from "@/components/ui/spoiler";

export function LongDescription() {
  return (
    <Spoiler maxHeight={80}>
      <SpoilerContent>
        <p>A hand-thrown cup in dark clay, fired twice, with a matte glaze on the outside.</p>
      </SpoilerContent>
      <SpoilerTrigger />
    </Spoiler>
  );
}
```

## Compose

Rules:

- Group with a Frame (`group-in-frames`): Put related panels in one `Frame` with its header and footer outside the panels, and keep a plain `Card` for one block of content.
- 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/spoiler
```

It adds 29 registry items: 26 files, 4083 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `clsx`, `motion`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Button](https://gelatinui.com/components/button.md)
- [Collapsible](https://gelatinui.com/components/collapsible.md)

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

- [Collapsible](https://gelatinui.com/components/collapsible.md): Pick Collapsible for a fold with its own title row that hides all of its panel.
- [Scroll Area](https://gelatinui.com/components/scroll-area.md)
- [Accordion](https://gelatinui.com/components/accordion.md): Pick Accordion for a stack of headings that each open their own panel, such as a FAQ.

## Keyboard

| Keys | Action |
| --- | --- |
| Enter, Space | Opens or closes it from the trigger. |

## Accessibility

It is the Base UI Collapsible, so the trigger has `aria-expanded`.

Closed, a Tab skips what is hidden.
