npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-collapsible.json --yesCollapsible
ProOne trigger that shows and hides the content right below it, such as more options, for React and Tailwind CSS. Part of Goop Pro.
What an agent sees
- CollapsibleHeaderThe row the trigger and its trailing control stand in
- CollapsibleTriggerThe header button that folds and unfolds the content
- CollapsibleActionA trailing glyph control in the header row, after the trigger and outside it
- CollapsibleContentWhat the section shows while open
import { Collapsible, CollapsibleHeader, CollapsibleTrigger, CollapsibleAction, CollapsibleContent } from '@/components/ui/goop/collapsible';
import { Card, CardContent } from '@/components/ui/goop/card';
import { Checkbox } from '@/components/ui/goop/checkbox';
import { Button } from '@/components/ui/goop/button';
<>
<Collapsible defaultOpen>
<CollapsibleHeader>
<CollapsibleTrigger>Details</CollapsibleTrigger>
</CollapsibleHeader>
<CollapsibleContent>…</CollapsibleContent>
</Collapsible>
<Card variant="outline">
<CardContent>
<Collapsible inset defaultOpen>
<CollapsibleHeader>
<Checkbox aria-label="Invite a teammate: done" />
<CollapsibleTrigger variant="item">Invite a teammate</CollapsibleTrigger>
</CollapsibleHeader>
<CollapsibleContent>
<Button size="sm" variant="outline">
Invite
</Button>
</CollapsibleContent>
</Collapsible>
</CardContent>
</Card>
</>Fold and unfold it from its header (click, Enter or Space); switch the trigger’s look, open at first, the action beside it (it adds a note), disabled. The notes are ours; nothing is pinned.
When to use
- One trigger that shows and hides the content right below it, such as more options.
- Also called: disclosure or expander.
When not to use
- For a stack of such sections use Accordion.
Installation
Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Collapsible on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-collapsible.json --yesAdd the Goop Collapsible to this project. The install steps are at https://goop.so/docs/install.mdUsage
import { Collapsible, CollapsibleHeader, CollapsibleTrigger, CollapsibleAction, CollapsibleContent } from '@/components/ui/goop/collapsible';
import { Card, CardContent } from '@/components/ui/goop/card';
import { Checkbox } from '@/components/ui/goop/checkbox';
import { Button } from '@/components/ui/goop/button';
<>
<Collapsible defaultOpen>
<CollapsibleHeader>
<CollapsibleTrigger>Details</CollapsibleTrigger>
</CollapsibleHeader>
<CollapsibleContent>…</CollapsibleContent>
</Collapsible>
<Card variant="outline">
<CardContent>
<Collapsible inset defaultOpen>
<CollapsibleHeader>
<Checkbox aria-label="Invite a teammate: done" />
<CollapsibleTrigger variant="item">Invite a teammate</CollapsibleTrigger>
</CollapsibleHeader>
<CollapsibleContent>
<Button size="sm" variant="outline">
Invite
</Button>
</CollapsibleContent>
</Collapsible>
</CardContent>
</Card>
</>- Fits: settings, flow: body.
- height, width, padding, gap, corner, background, text, motion: add no class for these.
API reference
| Option | Type | What it does |
|---|---|---|
| inset? | boolean = false | The section sits in a padded container: its header's wash bleeds past the edge, its words and content on it. |
| open? | boolean | |
| defaultOpen? | boolean = false | |
| onOpenChange? | (open: boolean) => void | |
| disabled? | boolean |
- State: open (open / defaultOpen / onOpenChange); drawn by data-state=open
| Part | What it is |
|---|---|
| CollapsibleHeader | The row the trigger and its trailing control stand in |
| CollapsibleTrigger | The header button that folds and unfolds the content; its children are the words before its caret; variant: default (default), item; takes asChild; mark?: ReactNode — A leading glyph before the words: the caller's one element, in a 14 px box |
| CollapsibleAction | A trailing glyph control in the header row, after the trigger and outside it; icon: IconName — The glyph's name in the theme's icon set (required); name the control with aria-label; also takes type?: 'button' | 'submit' | 'reset'; onClick?: (event: MouseEvent) => void; disabled?: boolean; aria-label: string; tooltip?: string | false; tooltipKeys?: readonly string[]; loading?: boolean = false; loadingLabel?: string = 'Loading' |
| CollapsibleContent | What the section shows while open; takes asChild |
- Class recipes (cva): collapsibleTriggerVariants (CollapsibleTrigger)
- data-slot values (to select a part by): collapsible, collapsible-action, collapsible-body, collapsible-content, collapsible-header, collapsible-icon, collapsible-indicator, collapsible-indicator-box, collapsible-inset, collapsible-label, collapsible-trigger
Keyboard
| Key | What it does |
|---|---|
| Enter | Activate |
| Space | Activate |
Accessibility
- The behaviour layer under the part answers keys, focus and dismissal: never write your own.
- hover, active, focus-visible, focus-within: the browser's own (:hover, :active, :focus-visible, :focus-within): write nothing
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| expanded | the attribute data-state=open |
| open | the attribute data-state=open |
| disabled | the prop disabled |
Motion
- The part sets its own motion: add no transition or animation of your own.
- How the theme moves, and how to move your own parts the same way: Motion.
Notes for AI
Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.