Skip to content
Logic2BUI

Search docs

Search components and documentation

New
Menu

Accordion

A vertically stacked set of interactive headings that each reveal a section of content.

Installation

npx logic2b@next add accordion

Usage

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

API reference

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

View JSON

Accordion

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

AccordionItem

Component
Props: React.ComponentProps<typeof AccordionPrimitive.Item>

AccordionTrigger

Component
Props: React.ComponentProps<typeof AccordionPrimitive.Trigger>

AccordionContent

Component
Props: React.ComponentProps<typeof AccordionPrimitive.Content>

Accessibility contract

Machine-readable behavior and consumer responsibilities for accordion.

View JSON
Support
Primitive-managed
Pattern
accordion
Radix Accordion
Keyboard interactions for accordion
KeysBehavior
Enter SpaceActivate the focused control.
ArrowUp ArrowDown Home EndMove 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.