# Accordion

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

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any URL or sending an `Accept: text/markdown` header. An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).

<DocsBaseSwitcher base="web" component="accordion" />

<ComponentPreview name="accordion" title="accordion.tsx">
<AccordionDemo />
</ComponentPreview>

Accordion reveals related content in place, one section at a time. It keeps long surfaces compact without requiring a new page or modal.

## Installation [#installation]

<CodeTabs>
<TabsList>
<TabsTrigger value="cli">
Command
</TabsTrigger>

<TabsTrigger value="manual">
Manual
</TabsTrigger>
</TabsList>

<TabsContent value="cli">
```bash
npx frakment add accordion
```
</TabsContent>

<TabsContent value="manual">
<Steps>
<Step>
Install the following dependencies:
</Step>

```bash
npm install lucide-react
```

<Step>
Copy and paste the following code into your project.
</Step>

<ComponentSource name="accordion" title="components/ui/accordion.tsx" />

<Step>
Update the import paths to match your project setup.
</Step>
</Steps>
</TabsContent>
</CodeTabs>

## Usage [#usage]

```tsx title="accordion.tsx"
import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionTrigger,
} from "@/components/ui/accordion";
```

```tsx title="accordion.tsx"
<Accordion collapsible defaultValue="shipping" type="single">
  <AccordionItem value="shipping">
    <AccordionTrigger>What are your shipping options?</AccordionTrigger>
    <AccordionContent>
      Standard, express, and overnight options available.
    </AccordionContent>
  </AccordionItem>
</Accordion>
```

## Examples [#examples]

### Basic [#basic]

A minimal accordion with three items.

<ComponentPreview name="accordion-basic" title="accordion-basic.tsx" src="examples/accordion-basic.tsx" previewClassName="h-auto py-8">
<AccordionBasic />
</ComponentPreview>

### Multiple [#multiple]

Use `type="multiple"` to allow several items open at the same time.

<ComponentPreview name="accordion-multiple" title="accordion-multiple.tsx" src="examples/accordion-multiple.tsx" previewClassName="h-auto py-8">
<AccordionMultiple />
</ComponentPreview>

### Disabled [#disabled]

Set `disabled` on an `AccordionItem` to lock it.

<ComponentPreview name="accordion-disabled" title="accordion-disabled.tsx" src="examples/accordion-disabled.tsx" previewClassName="h-auto py-8">
<AccordionDisabled />
</ComponentPreview>

### Borders [#borders]

Add borders around the container and between items for a boxed look.

<ComponentPreview name="accordion-borders" title="accordion-borders.tsx" src="examples/accordion-borders.tsx" previewClassName="h-auto py-8">
<AccordionBorders />
</ComponentPreview>

### Card [#card]

Nest an accordion inside a card for grouped, framed content.

<ComponentPreview name="accordion-card" title="accordion-card.tsx" src="examples/accordion-card.tsx" previewClassName="h-auto py-8">
<AccordionCard />
</ComponentPreview>

## In context [#in-context]

### FAQ section [#faq-section]

<ComponentPreview name="accordion-faq" title="accordion-faq.tsx" src="examples/accordion-faq.tsx">
<o />
</ComponentPreview>

## Motion [#motion]

Accordion accepts a `motion` prop on the root, inherited by every content item. Pass a per-item override on `AccordionContent` to diverge from the root setting. Pass `motion="off"` or `motion={false}` to disable the reveal.

```tsx
<Accordion collapsible motion="200 ease-out" type="single">
  <AccordionItem value="a">
    <AccordionTrigger>Question</AccordionTrigger>
    <AccordionContent motion="300 cubic-bezier(0.4, 0, 0.2, 1)">Answer</AccordionContent>
  </AccordionItem>
</Accordion>
```

`motion` follows the same string syntax as every other Frakment component: `"off"`, `"150"`, `"150 ease-out"`, or `"150 cubic-bezier(0.4, 0, 0.2, 1)"`. The default is a 450ms smooth-out curve. `prefers-reduced-motion` always wins — the reveal is instant when the user has reduced motion enabled.

## API Reference [#api-reference]

### Accordion [#accordion]

<PropsTable rows={[{"name":"type","type":"single | multiple","description":"Whether one or several items can be open at once."},{"name":"defaultValue","type":"string | string[]","description":"Item value(s) open on first render."},{"name":"value","type":"string | string[]","description":"Controlled open value(s)."},{"name":"onValueChange","type":"(value: string) => void | (value: string[]) => void","description":"Called when the open value changes. Single type receives a string, multiple receives a string array."},{"name":"collapsible","type":"boolean","default":"false","description":"When single, allow closing the open item."},{"name":"disabled","type":"boolean","default":"false","description":"Prevent all interaction."},{"name":"motion","type":"string","description":"Motion string for the open/close reveal. Inherited by every item. Pass off to disable."},{"name":"orientation","type":"horizontal | vertical","default":"vertical","description":"Arrow-key direction. Horizontal uses Left and Right."}]} />

### AccordionItem [#accordionitem]

<PropsTable rows={[{"name":"value","type":"string","description":"Unique identifier for the item. Required."},{"name":"disabled","type":"boolean","default":"false","description":"Prevent the item from opening."}]} />

### AccordionContent [#accordioncontent]

<PropsTable rows={[{"name":"motion","type":"string | false","description":"Per-item override for the reveal motion. Pass false to disable."}]} />

## Controlled [#controlled]

```tsx
const [value, setValue] = React.useState("item-1");

<Accordion onValueChange={setValue} type="single" value={value}>
  {/* ... */}
</Accordion>
```

## Keyboard [#keyboard]

| Key | Action |
| :-- | :-- |
| `Space` / `Enter` | Toggle the focused item |
| `↑` / `↓` | Move between triggers (vertical orientation) |
| `←` / `→` | Move between triggers (horizontal orientation) |
| `Home` / `End` | First / last trigger |

## Data Attributes [#data-attributes]

| Attribute | Values |
| :-- | :-- |
| `data-slot` | `accordion`, `accordion-item`, `accordion-header`, `accordion-trigger`, `accordion-content` |
| `data-state` | `open` \| `closed` |
| `data-orientation` | `vertical` \| `horizontal` |
| `data-disabled` | Present on disabled root, item, trigger, and content |

## Accessibility [#accessibility]

- Follows the WAI-ARIA disclosure pattern. Triggers expose `aria-expanded` and `aria-controls`; content is labeled with `aria-labelledby` and carries `role="region"`.
- `AccordionTrigger` renders inside an `AccordionHeader` (`<h3>`). Keep trigger text descriptive so the landmark is announced correctly.
- Keyboard: `Enter` and `Space` toggle an item; arrow keys move focus between triggers; `Home` and `End` jump to the first or last trigger.
- Content stays in the DOM and is marked inert while closed, so screen readers skip it and Tab does not enter it.

## Best Practices [#best-practices]

- **Keep content short per section.**
- **Use `type="single"` for FAQ-style lists.**
- **Use `type="multiple"` for settings panels.**
- **Reserve `defaultValue` for one item.**

## Related Components [#related-components]

- [Collapsible](/docs/components/collapsible): single expandable panel
- [Tabs](/docs/components/tabs): content panes