Collapsible
A single region that shows and hides from a trigger, with an optional height animation, built on the Radix Collapsible primitive.
Preview
Order #2041Priya Raman · ships Friday
$300.40Espresso grinder×1$189.00
Dark roast, 1 kg×2$46.00
Paper filters, 100 pack×1$6.50
Cleaning tablets×1$12.90
Install
Add the editable source with the shadcn CLI. Your project also needs the shared theme tokens this component uses. Setup and requirements. The Pebble installer is not published yet.
npx shadcn@latest add https://pebbleui.com/r/collapsible.jsonProps
| Prop | Type | Default | Description |
|---|---|---|---|
| open | boolean | - | Controlled open state (Collapsible). |
| defaultOpen | boolean | false | Initial open state when uncontrolled (Collapsible). |
| onOpenChange | (open: boolean) => void | - | Called when the trigger toggles (Collapsible). |
| disabled | boolean | false | Disables the trigger (Collapsible). |
| CollapsibleIndicator | React.ComponentProps<"svg"> | - | Chevron for inside a CollapsibleTrigger; rotates 180 degrees while open and is hidden from assistive tech. |
| asChild | boolean | false | Render your own element, e.g. a Button (CollapsibleTrigger, CollapsibleContent). |
| animated | boolean | true | Motion-safe height animation plus overflow-hidden; set false if children need to overflow (CollapsibleContent). |
Build notes
Radix `Collapsible` owns the state, ARIA wiring and the measured
`--radix-collapsible-content-height` variable on the content element (set from its
natural height when it opens and before it closes). Two keyframes, shipped in the
registry item `css` field: `collapsible-down` (height 0 to that variable) and
`collapsible-up` (the reverse), 200 ms ease-out, keyed on `data-state` under
`motion-safe:`. Radix's presence logic waits for the exit animation to end before
unmounting, so the close plays fully. The content gets `overflow-hidden` so children are
clipped while the height animates; this also clips focus rings and shadows of children
at the edge, which is why `animated={false}` exists (it removes both the animation and
the clipping). The motion-safe variant is used rather than a `motion-reduce:` override
because the `data-state` selectors are more specific and would win.
**Pebble (2026-11-03).** Timing moved to tokens: opening runs `collapsible-down` over `--motion-base` on `--motion-enter`, closing runs `collapsible-up` over the shorter `--motion-fast` on `--motion-exit`. The content also fades in on open through a third keyframe, `collapsible-fade-in` (opacity 0 to 1), run alongside `collapsible-down` in the same motion-safe `animate-[...]` list. An `@starting-style` transition does not work here: Radix sets `transition-duration: 0s` inline while it measures on mount, so the starting style is consumed with no transition. `CollapsibleTrigger` now always carries `group/collapsible-trigger` (merged with `className`), which lets the new `CollapsibleIndicator` rotate with `group-data-[state=open]/collapsible-trigger:rotate-180` over `--motion-base`/`ease-move` with no context, and lets consumers swap trigger labels the same way. The demo shows the Pebble card pattern (raised card, full-width hover-wash trigger row): an open order, a closed build log and a disabled locked draft.
<!-- PEBBLE-LICENSE -->View source
registry/layout/collapsible/collapsible.tsx
"use client";
/* PEBBLE-LICENSE
Built by Pebble. Component: collapsible.
First-party license: MIT
The following first-party terms apply only to original Pebble material.
MIT License
Copyright (c) 2026 Praxys Solutions LLC (Pebble)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
THIRD-PARTY NOTICES
These notices apply to identified upstream portions; Pebble terms do not replace or narrow their rights.
Upstream: https://raw.githubusercontent.com/shadcn-ui/ui/main/LICENSE.md
MIT License
Copyright (c) 2023 shadcn
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
END PEBBLE-LICENSE */
import * as React from "react";
import { Collapsible as CollapsiblePrimitive } from "radix-ui";
import { cn } from "@/lib/utils";
export function Collapsible(props: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />;
}
export function CollapsibleTrigger({
className,
...props
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
return (
<CollapsiblePrimitive.CollapsibleTrigger
data-slot="collapsible-trigger"
// Named group so a CollapsibleIndicator (or any child) can follow the
// trigger's data-state without React context.
className={cn("group/collapsible-trigger", className)}
{...props}
/>
);
}
export type CollapsibleIndicatorProps = React.ComponentProps<"svg">;
/**
* A chevron that turns half a turn when its CollapsibleTrigger is open. Place
* it inside the trigger; it is decorative (`aria-hidden`).
*/
export function CollapsibleIndicator({ className, ...props }: CollapsibleIndicatorProps) {
return (
<svg
data-slot="collapsible-indicator"
aria-hidden
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
className={cn(
"size-4 shrink-0 text-muted-foreground transition-transform duration-(--motion-base) ease-move motion-reduce:transition-none",
"group-data-[state=open]/collapsible-trigger:rotate-180",
className,
)}
{...props}
>
<path d="m4 6 4 4 4-4" />
</svg>
);
}
export type CollapsibleContentProps = React.ComponentProps<
typeof CollapsiblePrimitive.CollapsibleContent
> & {
/**
* Animate the panel height on open and close (motion-safe only). Turn off
* when the content needs to overflow its box, such as focus rings or
* shadows that would otherwise be clipped.
*/
animated?: boolean;
};
export function CollapsibleContent({
className,
animated = true,
...props
}: CollapsibleContentProps) {
return (
<CollapsiblePrimitive.CollapsibleContent
data-slot="collapsible-content"
className={cn(
// motion-safe, not a motion-reduce override: the data-state rules are
// more specific and would win over animate-none. Opening takes the
// base duration on the enter curve and fades the panel in alongside
// the height (a keyframe, not a transition: Radix zeroes the
// transition while it measures on mount); closing is quicker on the
// exit curve.
animated &&
"overflow-hidden motion-safe:data-[state=closed]:animate-[collapsible-up_var(--motion-fast)_var(--motion-exit)] motion-safe:data-[state=open]:animate-[collapsible-down_var(--motion-base)_var(--motion-enter),collapsible-fade-in_var(--motion-base)_var(--motion-enter)]",
className,
)}
{...props}
/>
);
}
