---
title: "Collapsible"
description: "One button that shows and hides a panel of content under it."
url: https://gelatinui.com/components/collapsible
markdown_url: https://gelatinui.com/components/collapsible.md
access: free
install: "npx shadcn@latest add @gelatin-ui/collapsible"
registry_item: https://gelatinui.com/r/collapsible.json
version: "2026-11-08"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Collapsible

> One button that shows and hides a panel of content under it.

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

## When to use it

Best for: One button that shows and hides one panel of content under it.

- Use it to hide one panel of content until the user asks for it.
- Render a Button through `render` on `CollapsibleTrigger`, and keep its text the same when it opens.
- Put the space between the trigger and the content on `CollapsibleContent` (`className="pt-2"`), so the page does not jump.

## When not to use it

- For content over the page, use a [Dialog](https://gelatinui.com/components/dialog.md).

## Notes for agents

- Compose `Collapsible`, `CollapsibleTrigger`, and `CollapsibleContent`; render a Button through `render` on the trigger.
- Put the gap on `CollapsibleContent`, not on the trigger, so the panel height animates with no jump.

## Anatomy

```text
Collapsible
├─ CollapsibleTrigger (0..n)
├─ CollapsibleChevron (0..n)
└─ CollapsibleContent (0..n)
```

## API reference

### Collapsible

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

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

### CollapsibleTrigger

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

### CollapsibleChevron

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `direction` | `"down" \| "end"` |  | `down` (default) for a panel that opens below, `end` for a row that opens rows under it. |
| `variant` | `"bulk" \| "duotone" \| "solid" \| "stroke" \| "twotone"` |  | `stroke` (default): 1.5 strokes. `solid`: the body filled, inner details cut through. `duotone`: a 40% fill under the stroke. `twotone`: the details at 40%. `bulk`: the body filled at 40% with no outline, the details at full color. |
| `corners` | `"round" \| "sharp"` |  | `round` (default): round caps and joins, soft corners. `sharp`: square caps, miter joins. |
| `open` | `boolean` |  | Open: the chevron turns (down → up, end → down) on the `panelBounce` spring. |

### CollapsibleContent

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

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

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| Collapsible | `collapsible` |  |  |  |
| CollapsibleTrigger | `collapsible-trigger` | `data-disabled` |  |  |
| CollapsibleChevron | `collapsible-chevron` |  |  |  |
| CollapsibleContent | `collapsible-content` |  |  |  |

## Usage

Render a Button through `render` on `CollapsibleTrigger`. Put the space above the content on `CollapsibleContent` (`className="pt-2"`), not as a `gap` on the root, so the page does not jump.

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

```tsx title="advanced-options.tsx"
import { CaretDownIcon } from "@phosphor-icons/react/ssr";

import { Button } from "@/components/ui/button";
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
import { disclosureChevronVariants } from "@/lib/disclosure-context";

export function AdvancedOptions() {
  return (
    <Collapsible>
      <CollapsibleTrigger render={<Button variant="ghost" size="sm" />}>
        Advanced options
        <CaretDownIcon aria-hidden data-icon="inline-end" className={disclosureChevronVariants()} />
      </CollapsibleTrigger>
      <CollapsibleContent className="pt-2">
        <p className="text-sm text-muted-foreground">Set a custom domain and a webhook URL.</p>
      </CollapsibleContent>
    </Collapsible>
  );
}
```

## 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/collapsible
```

It adds 12 registry items: 11 files, 2417 lines, and the npm packages `@base-ui/react`, `clsx`, `motion`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Animated Chevron Icon](https://gelatinui.com/components/animated-chevron-icon.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

- [Animated Chevron Icon](https://gelatinui.com/components/animated-chevron-icon.md)
- [Button](https://gelatinui.com/components/button.md)
- [Dialog](https://gelatinui.com/components/dialog.md)
- [Accordion](https://gelatinui.com/components/accordion.md): Pick Accordion for a stack of headings where each one opens its own panel.
- [Spoiler](https://gelatinui.com/components/spoiler.md): Pick Spoiler to cut long content at a height with a fade and a Show more button, with no title row.

## Keyboard

| Keys | Action |
| --- | --- |
| Enter | Opens or closes the panel. |
| Space | Opens or closes the panel. |

## Accessibility

`CollapsibleTrigger` is a Base UI `Collapsible.Trigger`, a button. Base UI sets `aria-expanded` on it, and `aria-controls` to the panel while the panel is open.

Name the trigger by what the panel shows ("Advanced options"). Keep the text the same when it opens: `aria-expanded` says the state.

Render a Button as the trigger: it then has the focus ring, and on a coarse pointer `hit-area` grows its touch target to at least 44 × 44px.

## Motion

| Part | Motion |
| --- | --- |
| Open and close | panel · 260ms · ease-panel (0.2, 0.4, 0.2, 1) · the height and the chevron turn |
| Content in | fade · 150ms · ease-out (0, 0, 0.2, 1) |
| Content out | fade-exit · 90ms · ease-out (0, 0, 0.2, 1) |
