Installation
npx logic2b@next add accordionUsage
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/components/ui/accordion"
<Accordion type="single" collapsible>
<AccordionItem value="item-1">
<AccordionTrigger>Is it accessible?</AccordionTrigger>
<AccordionContent>
Yes. It adheres to the WAI-ARIA design pattern.
</AccordionContent>
</AccordionItem>
</Accordion>
Examples
Multiple
Set type="multiple" to let more than one section stay open at a time.
Controlled
Drive the open item externally with value and onValueChange.
The open item is driven by external state.
Accessibility
- Follows the WAI-ARIA Accordion pattern.
- Space or Enter toggles the focused section.
- Arrow Up / Arrow Down move focus between triggers, and Home / End jump to the first/last.
- Each trigger sits inside a heading and exposes
aria-expandedandaria-controlslinking it to its panel.
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
<Accordion
type="single"
defaultValue="item-1"
collapsible
>
<AccordionItem
value="item-1"
>
<AccordionTrigger>What is logic2b ui?</AccordionTrigger>
<AccordionContent>A registry built for people and coding agents.</AccordionContent>
</AccordionItem>
<AccordionItem
value="item-2"
>
<AccordionTrigger>Can I own the source?</AccordionTrigger>
<AccordionContent>Yes. Components are copied into your application.</AccordionContent>
</AccordionItem>
</Accordion>A registry built for people and coding agents.
API reference
Generated from the public TypeScript exports in src/ui/accordion.tsx.
Accordion
ComponentProps: React.ComponentProps<typeof AccordionPrimitive.Root>AccordionItem
ComponentProps: React.ComponentProps<typeof AccordionPrimitive.Item>AccordionTrigger
ComponentProps: React.ComponentProps<typeof AccordionPrimitive.Trigger>AccordionContent
ComponentProps: React.ComponentProps<typeof AccordionPrimitive.Content>Accessibility contract
Machine-readable behavior and consumer responsibilities for accordion.
- Support
- Primitive-managed
- Pattern
- accordion
- Radix Accordion
| Keys | Behavior |
|---|---|
| Enter Space | Activate the focused control. |
| ArrowUp ArrowDown Home End | Move between accordion triggers. |
Built-in semantics
- Triggers expose aria-expanded and aria-controls; panels are linked to their headings.
Consumer responsibilities
- Use concise trigger text and preserve the heading hierarchy.