@logic2b starred 3 repositories
@radix-ui/primitives
Installation
npx logic2b@next add collapsibleUsage
import {
Collapsible,
CollapsibleContent,
CollapsibleTrigger,
} from "@/components/ui/collapsible"
<Collapsible>
<CollapsibleTrigger>Can I use this in my project?</CollapsibleTrigger>
<CollapsibleContent>
Yes. Free to use for personal and commercial projects.
</CollapsibleContent>
</Collapsible>
Examples
Controlled
Drive the open state with open and onOpenChange.
Show environment variables
NEXT_PUBLIC_API_URL
FAQ item
Compose a self-contained expandable panel with a bordered trigger.
Accessibility
- The trigger exposes
aria-expandedandaria-controlspointing at the collapsible content. - Space or Enter on the focused trigger toggles the panel.
- When collapsed the content is hidden from assistive technology and removed from the tab order.
Live playground
Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.
Generated JSX
<Collapsible
defaultOpen
>
<CollapsibleTrigger
className="w-full rounded-md border px-4 py-2 text-left text-sm font-medium"
>Repository details</CollapsibleTrigger>
<CollapsibleContent
className="mt-2 rounded-md bg-muted p-4 text-sm text-muted-foreground"
>React 19 · Tailwind v4 · Cloudflare Workers</CollapsibleContent>
</Collapsible>React 19 · Tailwind v4 · Cloudflare Workers
API reference
Generated from the public TypeScript exports in src/ui/collapsible.tsx.
Collapsible
ComponentProps: React.ComponentProps<typeof CollapsiblePrimitive.Root>CollapsibleTrigger
ComponentProps: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>CollapsibleContent
ComponentProps: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>Accessibility contract
Machine-readable behavior and consumer responsibilities for collapsible.
- Support
- Primitive-managed
- Pattern
- disclosure
- Radix Collapsible
| Keys | Behavior |
|---|---|
| Enter Space | Activate the focused control. |
Built-in semantics
- The trigger manages aria-expanded and aria-controls for its content.
Consumer responsibilities
- Use a button-like trigger with text that describes the hidden content.