Skip to content
Logic2BUI

Search docs

Search components and documentation

New
Menu

Collapsible

An interactive component which expands and collapses a panel of content.

@logic2b starred 3 repositories

@radix-ui/primitives

Installation

npx logic2b@next add collapsible

Usage

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-expanded and aria-controls pointing 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>

API reference

Generated from the public TypeScript exports in src/ui/collapsible.tsx.

View JSON

Collapsible

Component
Props: React.ComponentProps<typeof CollapsiblePrimitive.Root>

CollapsibleTrigger

Component
Props: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>

CollapsibleContent

Component
Props: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>

Accessibility contract

Machine-readable behavior and consumer responsibilities for collapsible.

View JSON
Support
Primitive-managed
Pattern
disclosure
Radix Collapsible
Keyboard interactions for collapsible
KeysBehavior
Enter SpaceActivate 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.