# Accordion

Show one section at a time, or several, and keep long pages scannable.

- Category: Core Elements
- Page: https://wunderui.com/components/accordion
- Tier: Free

## Install

```bash
npx wunderui-cli add accordion
```

## Import

```tsx
import { Accordion, AccordionAppearance, AccordionContent, AccordionDensity, AccordionFeedback, AccordionHeadingLevel, AccordionItem, AccordionRow, AccordionTrigger } from "@/components/ui/accordion"
```

## Minimal usage

Then use it:

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

export function Faq() {
  return (
    <Accordion appearance="divided" density="default" defaultValue={["refunds"]}>
      <AccordionItem value="refunds">
        <AccordionTrigger>How long does a refund take?</AccordionTrigger>
        <AccordionContent>Refunds reach your original payment method within 5 to 7 business days after approval.</AccordionContent>
      </AccordionItem>
      <AccordionItem value="password">
        <AccordionTrigger>How do I reset my password?</AccordionTrigger>
        <AccordionContent>Open Settings, choose Security and select Reset password.</AccordionContent>
      </AccordionItem>
      <AccordionItem value="plan">
        <AccordionTrigger>Can I change my billing plan?</AccordionTrigger>
        <AccordionContent>You can change your plan at any time in Billing; changes apply immediately.</AccordionContent>
      </AccordionItem>
    </Accordion>
  )
}
```

Expected result: You should see three rows; the first one is open.

## Usage

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

export function Example() {
  return (
    <Accordion appearance="divided" density="default" defaultValue={["billing"]}>
      <AccordionItem value="billing">
        <AccordionTrigger>Billing and invoices</AccordionTrigger>
        <AccordionContent>Invoices are issued on the first day of each month and sent to the billing contact. You can download past invoices as PDF files.</AccordionContent>
      </AccordionItem>
      <AccordionItem value="team">
        <AccordionTrigger>Team members</AccordionTrigger>
        <AccordionContent>Invite colleagues by email and assign a role. Owners can manage billing, members can edit projects.</AccordionContent>
      </AccordionItem>
      <AccordionItem value="security">
        <AccordionTrigger>Security</AccordionTrigger>
        <AccordionContent>Turn on two-factor sign-in and review the devices that are signed in to your workspace.</AccordionContent>
      </AccordionItem>
    </Accordion>
  )
}
```

## When to use

### Use Accordion for

- FAQs and help pages, where people read one answer at a time
- Grouped settings, such as account, billing and notifications
- Long forms split into sections or steps, such as a checkout

### Use something else

- [Collapsible](https://wunderui.com/components/collapsible) for a single show-more panel
- [Tabs](https://wunderui.com/components/tabs) for peer views of one object that people switch between
- [Dialog](https://wunderui.com/components/dialog) for a task that must block the page until it is done

## Keyboard

The trigger is a native button, so the browser provides focus and activation.

| Key | Action |
|---|---|
| `Tab` or `Shift+Tab` | Moves focus to the next or previous trigger, and to any control placed beside it with `AccordionRow`. |
| `Enter` or `Space` | Opens or closes the focused row. In single mode, opening a row closes the open one. |

Arrow keys, Home and End do not move focus between rows in this version.

## Behavior

What the list does with state, content, the DOM and motion.

- **Disabled rows:** A disabled item stays focusable and is announced as disabled, but it cannot be toggled. It is drawn at 40 % opacity.
- **Closed panels are not in the DOM:** Closed panels are not rendered by default, so their text is missing from page search and form values inside are lost. You can keep them mounted or let find-in-page open them.
- **Values are arrays:** Values are always arrays of item values, even in single mode, where the array holds at most one. Allow several open rows to hold more.
- **Always set the look:** Look and density are optional. Without a look you get the legacy spaced cards with a +/- button, and rows are 48 px high, so set both in new code.
- **Headings:** Every trigger sits in an h3 by default. Set a heading level from 2 to 6 on the list or on one trigger so the rows fit your page outline.
- **Opening and closing:** Panels grow and shrink with their content. Opening takes the base duration, and closing is one step faster so a dismissed panel does not linger.
- **Indicators:** The plus, minus and cross indicators crossfade in place instead of swapping.
- **Reduced motion:** With reduced motion on, the panel opens and closes instantly and the indicators only fade. Colour changes stay.

## Anatomy

- `Accordion`: Tracks which items are open: one at a time by default, several if you allow it. You pick a look (plain, divided, contained, separated) and a density.
- `AccordionItem`: One section of the list. It draws the divider, the card or the hover fill, depending on the look of the list.
- `AccordionTrigger`: The header row: a real button inside a heading. It can hold a leading icon, a second line, a slot for extra info and an indicator.
- `Label`: The question or section name inside the trigger. It is also the button's accessible name.
- `Meta`: A slot between the label and the indicator, for a counter, a status or a short value.
- `Indicator`: The chevron or plus that shows whether the item is open. Its style and position follow the look of the list unless you set them.
- `AccordionContent`: The panel under the trigger. It opens smoothly to the height of its content, and its text lines up with the label.
- `AccordionRow`: Wraps the trigger so a control can sit beside it, not inside it: a checkbox or switch on the left, or an action button such as Edit.
- `AccordionFeedback`: The loading, empty and error content of a panel, with an optional action such as Retry.

## Best practices

### Do

- Pick one look per list: divided or plain on a page, contained as one card, separated for stand-alone sections.
- Use the compact density (36 px rows) in side panels and the default (48 px rows) everywhere else.
- Allow several open items when people compare answers. By default, opening one closes the other.
- Write the trigger as the question or section name in sentence case, like How do refunds work? It is the button's accessible name.
- Put controls beside the trigger with AccordionRow. The trigger stays a single button and the control gets its own Tab stop.

### Don't

- Don't put buttons or links inside the trigger. The whole row is already a button, and a button inside a button is invalid HTML.
- Don't hide what people must read or do in a closed row. Required information and primary actions belong outside the accordion.

## API reference

### Accordion

| Prop | Type | Default | Description |
|---|---|---|---|
| appearance | "plain" \| "divided" \| "contained" \| "separated" |  | Visual look of the list: `plain`, `divided`, `contained` or `separated`. Without it the list keeps the legacy look (spaced cards with a +/− button), so always set it. |
| className | string \| ((state: State) => string \| undefined) |  | CSS class applied to the element, or a function that returns a class based on the component's state. |
| defaultValue | string[] |  | The values of the items that start open, for an uncontrolled accordion. |
| density | "compact" \| "default" | "default" | Row height: `default` is 48 px, `compact` is 36 px. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| headingLevel | 2 \| 3 \| 4 \| 5 \| 6 | 3 | Heading level of every trigger, 2 to 6. Defaults to 3. |
| hiddenUntilFound | boolean | false | Allows the browser's built-in page search to find and expand the panel contents. Overrides the `keepMounted` prop and uses `hidden="until-found"` to hide the element without removing it from the DOM. |
| keepMounted | boolean | false | Whether to keep the element in the DOM while the panel is closed. This prop is ignored when `hiddenUntilFound` is used. |
| loopFocus | boolean |  | Deprecated following the [APG guidance update](https://github.com/w3c/aria-practices/pull/3434) to remove roving focus. This prop no longer affects keyboard focus behavior. No effect in this version. Arrow keys do not move focus in this version, so there is no focus to loop. |
| multiple | boolean | false | Whether multiple items can be open at the same time. |
| onValueChange | (value: string[]) => void |  | Called with the new array of open item values whenever a row opens or closes. |
| orientation | "horizontal" \| "vertical" | 'vertical' | Deprecated following the [APG guidance update](https://github.com/w3c/aria-practices/pull/3434) to remove roving focus. This prop no longer affects keyboard focus behavior. No effect in this version. The accordion is always vertical in this version. |
| render | React.ReactElement \| ComponentRenderFn<RenderFunctionProps, State> |  | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties \| ((state: State) => React.CSSProperties \| undefined) |  | Style applied to the element, or a function that returns a style object based on the component's state. |
| value | string[] |  | The values of the open items, for a controlled accordion. In single mode the array holds at most one value. |

Also accepts React.HTMLAttributes attributes.

### AccordionContent

| Prop | Type | Default | Description |
|---|---|---|---|
| className | string \| ((state: State) => string \| undefined) |  | CSS class applied to the element, or a function that returns a class based on the component's state. |
| hiddenUntilFound | boolean | false | Allows the browser's built-in page search to find and expand the panel contents. Overrides the `keepMounted` prop and uses `hidden="until-found"` to hide the element without removing it from the DOM. |
| keepMounted | boolean | false | Whether to keep the element in the DOM while the panel is closed. This prop is ignored when `hiddenUntilFound` is used. |
| render | React.ReactElement \| ComponentRenderFn<RenderFunctionProps, State> |  | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties \| ((state: State) => React.CSSProperties \| undefined) |  | Style applied to the element, or a function that returns a style object based on the component's state. |

Also accepts React.HTMLAttributes attributes.

### AccordionFeedback

| Prop | Type | Default | Description |
|---|---|---|---|
| kind* | "loading" \| "empty" \| "error" |  | Which state the panel shows: `loading`, `empty` or `error`. |
| action | React.ReactNode |  | Action under the text, such as a Retry button. |
| className | string |  | Extra classes for the feedback block. |
| description | React.ReactNode |  | Supporting line under the title. |
| loadingLabel | string |  | Text under the skeleton while loading. Defaults to `Loading…`. |
| title | React.ReactNode |  | Heading of the empty and error states. |

### AccordionItem

| Prop | Type | Default | Description |
|---|---|---|---|
| className | string \| ((state: State) => string \| undefined) |  | CSS class applied to the element, or a function that returns a class based on the component's state. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| onOpenChange | ((open: boolean, eventDetails: AccordionItem.ChangeEventDetails) => void) |  | Event handler called when the panel is opened or closed. |
| render | React.ReactElement \| ComponentRenderFn<RenderFunctionProps, State> |  | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties \| ((state: State) => React.CSSProperties \| undefined) |  | Style applied to the element, or a function that returns a style object based on the component's state. |
| value | any |  | A unique value that identifies this accordion item. If no value is provided, a unique ID will be generated automatically. Use when controlling the accordion programmatically, or to set an initial open state. |
| variant | "card" \| "divider" |  | Legacy frame of the item: `card` or `divider`. Leave it out when you set `appearance` on the root; the appearance decides. |

Also accepts React.HTMLAttributes attributes.

### AccordionRow

| Prop | Type | Default | Description |
|---|---|---|---|
| children* | React.ReactNode |  | The `AccordionTrigger` of the row. |
| action | React.ReactNode |  | Control after the trigger, such as an Edit button. It stays outside the trigger. |
| className | string |  | Extra classes for the row. |
| leading | React.ReactNode |  | Control before the trigger, such as a checkbox or a switch. It stays outside the trigger. |

### AccordionTrigger

| Prop | Type | Default | Description |
|---|---|---|---|
| className | string \| ((state: State) => string \| undefined) |  | CSS class applied to the element, or a function that returns a class based on the component's state. |
| description | React.ReactNode |  | Optional second line under the label. |
| headingLevel | 2 \| 3 \| 4 \| 5 \| 6 |  | Heading level of this trigger, 2 to 6. Overrides the level set on `Accordion`. |
| icon | React.ReactNode |  | Optional leading decorative icon. |
| iconVariant | "plain" \| "box" | "box" | "box" puts the leading icon in a bordered square, "plain" renders it bare. |
| indicatorPosition | "leading" \| "trailing" | "trailing" | Where that affordance sits relative to the label. |
| indicatorVariant | "button" \| "plus" \| "chevron" |  | The open/close affordance: bordered +/− button, bare +/×, or a chevron. |
| meta | React.ReactNode |  | Trailing content between the label and the open/close indicator. |
| nativeButton | boolean | true | Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`). |
| render | React.ReactElement \| ComponentRenderFn<RenderFunctionProps, State> |  | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties \| ((state: State) => React.CSSProperties \| undefined) |  | Style applied to the element, or a function that returns a style object based on the component's state. |

Also accepts React.ButtonHTMLAttributes attributes.

## Examples

### Appearance: plain, divided, contained, separated

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

export function Example() {
  return (
    <Accordion appearance="divided" density="default" defaultValue={["billing"]}>
      <AccordionItem value="billing">
        <AccordionTrigger>Billing and invoices</AccordionTrigger>
        <AccordionContent>Invoices are issued on the first day of each month and sent to the billing contact. You can download past invoices as PDF files.</AccordionContent>
      </AccordionItem>
      <AccordionItem value="team">
        <AccordionTrigger>Team members</AccordionTrigger>
        <AccordionContent>Invite colleagues by email and assign a role. Owners can manage billing, members can edit projects.</AccordionContent>
      </AccordionItem>
      <AccordionItem value="security">
        <AccordionTrigger>Security</AccordionTrigger>
        <AccordionContent>Turn on two-factor sign-in and review the devices that are signed in to your workspace.</AccordionContent>
      </AccordionItem>
    </Accordion>
  )
}
```

### Behavior: single open and multiple open

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

export function Example() {
  return (
    <Accordion appearance="divided" density="default" defaultValue={["billing"]}>
      <AccordionItem value="billing">
        <AccordionTrigger>Billing and invoices</AccordionTrigger>
        <AccordionContent>Invoices are issued on the first day of each month and sent to the billing contact. You can download past invoices as PDF files.</AccordionContent>
      </AccordionItem>
      <AccordionItem value="team">
        <AccordionTrigger>Team members</AccordionTrigger>
        <AccordionContent>Invite colleagues by email and assign a role. Owners can manage billing, members can edit projects.</AccordionContent>
      </AccordionItem>
      <AccordionItem value="security">
        <AccordionTrigger>Security</AccordionTrigger>
        <AccordionContent>Turn on two-factor sign-in and review the devices that are signed in to your workspace.</AccordionContent>
      </AccordionItem>
    </Accordion>
  )
}
```

### Density: default and compact

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

export function Example() {
  return (
    <Accordion appearance="contained" density="default" defaultValue={["billing"]}>
      <AccordionItem value="billing">
        <AccordionTrigger>Billing and invoices</AccordionTrigger>
        <AccordionContent>Invoices are issued on the first day of each month and sent to the billing contact. You can download past invoices as PDF files.</AccordionContent>
      </AccordionItem>
      <AccordionItem value="team">
        <AccordionTrigger>Team members</AccordionTrigger>
        <AccordionContent>Invite colleagues by email and assign a role. Owners can manage billing, members can edit projects.</AccordionContent>
      </AccordionItem>
      <AccordionItem value="security">
        <AccordionTrigger>Security</AccordionTrigger>
        <AccordionContent>Turn on two-factor sign-in and review the devices that are signed in to your workspace.</AccordionContent>
      </AccordionItem>
    </Accordion>
  )
}
```

### Item types: basic, icon, description, counter, status, progress, error summary, metadata, restricted

```tsx
import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionTrigger,
} from "@/components/ui/accordion"
import { Badge } from "@/components/ui/badge"
import { Lock, User } from "lucide-react"

export function Example() {
  return (
    <div className="@container mx-auto flex w-full max-w-[640px] flex-col">
      <div className="grid grid-cols-1 gap-1 @[560px]:grid-cols-[96px_minmax(0,1fr)] @[560px]:items-center">
        <span className="text-xs text-text-secondary">Basic</span>
        <Accordion appearance="divided" density="default">
          <AccordionItem value="row">
            <AccordionTrigger>Shipping policy</AccordionTrigger>
            <AccordionContent>Short answer text for the section.</AccordionContent>
          </AccordionItem>
        </Accordion>
      </div>
      <div className="grid grid-cols-1 gap-1 @[560px]:grid-cols-[96px_minmax(0,1fr)] @[560px]:items-center">
        <span className="text-xs text-text-secondary">Icon</span>
        <Accordion appearance="divided" density="default">
          <AccordionItem value="row" className="first:border-t-0">
            <AccordionTrigger icon={<User />} iconVariant="plain">Profile settings</AccordionTrigger>
            <AccordionContent>Short answer text for the section.</AccordionContent>
          </AccordionItem>
        </Accordion>
      </div>
      <div className="grid grid-cols-1 gap-1 @[560px]:grid-cols-[96px_minmax(0,1fr)] @[560px]:items-center">
        <span className="text-xs text-text-secondary">Description</span>
        <Accordion appearance="divided" density="default">
          <AccordionItem value="row" className="first:border-t-0">
            <AccordionTrigger description="Cards and bank accounts used for invoices">Payment methods</AccordionTrigger>
            <AccordionContent>Short answer text for the section.</AccordionContent>
          </AccordionItem>
        </Accordion>
      </div>
      <div className="grid grid-cols-1 gap-1 @[560px]:grid-cols-[96px_minmax(0,1fr)] @[560px]:items-center">
        <span className="text-xs text-text-secondary">Counter</span>
        <Accordion appearance="divided" density="default">
          <AccordionItem value="row" className="first:border-t-0">
            <AccordionTrigger meta={<Badge color="grey" badgeStyle="light" shape="pill" className="h-5 px-2 text-xs">4</Badge>}>Attachments</AccordionTrigger>
            <AccordionContent>Short answer text for the section.</AccordionContent>
          </AccordionItem>
        </Accordion>
      </div>
      <div className="grid grid-cols-1 gap-1 @[560px]:grid-cols-[96px_minmax(0,1fr)] @[560px]:items-center">
        <span className="text-xs text-text-secondary">Status</span>
        <Accordion appearance="divided" density="default">
          <AccordionItem value="row" className="first:border-t-0">
            <AccordionTrigger meta={<Badge color="yellow" badgeStyle="light" shape="pill" className="h-5 px-2 text-xs">Action required</Badge>}>Billing</AccordionTrigger>
            <AccordionContent>Short answer text for the section.</AccordionContent>
          </AccordionItem>
        </Accordion>
      </div>
      <div className="grid grid-cols-1 gap-1 @[560px]:grid-cols-[96px_minmax(0,1fr)] @[560px]:items-center">
        <span className="text-xs text-text-secondary">Progress</span>
        <Accordion appearance="divided" density="default">
          <AccordionItem value="row" className="first:border-t-0">
            <AccordionTrigger meta={<span className="font-medium">3 of 5 completed</span>}>Profile</AccordionTrigger>
            <AccordionContent>Short answer text for the section.</AccordionContent>
          </AccordionItem>
        </Accordion>
      </div>
      <div className="grid grid-cols-1 gap-1 @[560px]:grid-cols-[96px_minmax(0,1fr)] @[560px]:items-center">
        <span className="text-xs text-text-secondary">Error summary</span>
        <Accordion appearance="divided" density="default">
          <AccordionItem value="row" className="first:border-t-0">
            <AccordionTrigger meta={<Badge color="red" badgeStyle="light" shape="pill" className="h-5 px-2 text-xs">2 errors</Badge>}>Shipping address</AccordionTrigger>
            <AccordionContent>Short answer text for the section.</AccordionContent>
          </AccordionItem>
        </Accordion>
      </div>
      <div className="grid grid-cols-1 gap-1 @[560px]:grid-cols-[96px_minmax(0,1fr)] @[560px]:items-center">
        <span className="text-xs text-text-secondary">Metadata</span>
        <Accordion appearance="divided" density="default">
          <AccordionItem value="row" className="first:border-t-0">
            <AccordionTrigger meta={<span className="font-medium">Email and push</span>}>Notifications</AccordionTrigger>
            <AccordionContent>Short answer text for the section.</AccordionContent>
          </AccordionItem>
        </Accordion>
      </div>
      <div className="grid grid-cols-1 gap-1 @[560px]:grid-cols-[96px_minmax(0,1fr)] @[560px]:items-center">
        <span className="text-xs text-text-secondary">Restricted</span>
        <Accordion appearance="divided" density="default">
          <AccordionItem value="row" disabled className="first:border-t-0">
            <AccordionTrigger icon={<Lock />} iconVariant="plain" description="Available on the Team plan">Audit log</AccordionTrigger>
            <AccordionContent>Short answer text for the section.</AccordionContent>
          </AccordionItem>
        </Accordion>
      </div>
    </div>
  )
}
```

### States: default, hover, pressed, focus visible and disabled, collapsed and expanded

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

export function Example() {
  return (
    <Accordion appearance="divided" density="default">
      <AccordionItem value="payment">
        <AccordionTrigger>Payment methods</AccordionTrigger>
        <AccordionContent>Cards and bank accounts used for invoices.</AccordionContent>
      </AccordionItem>
    </Accordion>
  )
}
```

### Content state: ready, loading, empty and error

```tsx
import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionTrigger,
} from "@/components/ui/accordion"
import { Badge } from "@/components/ui/badge"

export function Example() {
  return (
    <Accordion appearance="divided" density="default" defaultValue={["attachments"]}>
      <AccordionItem value="attachments">
        <AccordionTrigger meta={<Badge color="grey" badgeStyle="light" shape="pill" className="h-5 px-2 text-xs">3</Badge>}>Attachments</AccordionTrigger>
        <AccordionContent>Three files are attached to this request. Open one to preview it.</AccordionContent>
      </AccordionItem>
    </Accordion>
  )
}
```

### Beside the trigger: action and selectable sections

```tsx
import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionRow,
  AccordionTrigger,
} from "@/components/ui/accordion"
import { Button } from "@/components/ui/button"
import { Checkbox } from "@/components/ui/checkbox"
import { Switch } from "@/components/ui/switch"

export function Example() {
  return (
    <div className="@container mx-auto flex w-full max-w-[640px] flex-col">
      <div className="grid grid-cols-1 gap-1 @[560px]:grid-cols-[72px_minmax(0,1fr)] @[560px]:items-center">
        <span className="text-xs text-text-secondary">Action</span>
        <Accordion appearance="divided" density="default">
          <AccordionItem value="row">
            <AccordionRow action={<Button variant="plain" size="sm">Edit</Button>}>
              <AccordionTrigger description="14 Garden Street, Berlin">Billing address</AccordionTrigger>
            </AccordionRow>
            <AccordionContent>The address on your invoices. Changes apply to the next one.</AccordionContent>
          </AccordionItem>
        </Accordion>
      </div>
      <div className="grid grid-cols-1 gap-1 @[560px]:grid-cols-[72px_minmax(0,1fr)] @[560px]:items-center">
        <span className="text-xs text-text-secondary">Checkbox</span>
        <Accordion appearance="divided" density="default">
          <AccordionItem value="row" className="first:border-t-0">
            <AccordionRow leading={<Checkbox aria-label="Include invoices in the export" />}>
              <AccordionTrigger>Include invoices in the export</AccordionTrigger>
            </AccordionRow>
            <AccordionContent>Invoices are added to the monthly export as PDF files.</AccordionContent>
          </AccordionItem>
        </Accordion>
      </div>
      <div className="grid grid-cols-1 gap-1 @[560px]:grid-cols-[72px_minmax(0,1fr)] @[560px]:items-center">
        <span className="text-xs text-text-secondary">Switch</span>
        <Accordion appearance="divided" density="default">
          <AccordionItem value="row" className="first:border-t-0">
            <AccordionRow leading={<Switch defaultChecked aria-label="Weekly digest" />}>
              <AccordionTrigger>Weekly digest</AccordionTrigger>
            </AccordionRow>
            <AccordionContent>A summary of last week’s activity, sent every Monday.</AccordionContent>
          </AccordionItem>
        </Accordion>
      </div>
    </div>
  )
}
```

## In context

### FAQ: divided accordion with long answers and a link

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

export function FaqExample() {
  return (
    <div className="mx-auto w-full max-w-[640px]">
      <Accordion appearance="divided" density="default" defaultValue={["password"]}>
        <AccordionItem value="refund">
          <AccordionTrigger>
            How long does a refund take?
          </AccordionTrigger>
          <AccordionContent>
            Refunds are processed within 5 to 7 business days after approval and appear on your original payment method.
          </AccordionContent>
        </AccordionItem>
        <AccordionItem value="password">
          <AccordionTrigger>
            How do I reset my password?
          </AccordionTrigger>
          <AccordionContent>
            Open Settings, choose Security and select Reset password. We send a confirmation link to your email address, and
            it stays valid for 30 minutes. If the email does not arrive, check your spam folder or{" "}
            <a
              href="#"
              className="rounded-sm text-text-link underline decoration-text-link/40 underline-offset-4 hover:decoration-text-link focus-ring"
            >
              contact support
            </a>
            .
          </AccordionContent>
        </AccordionItem>
        <AccordionItem value="plan">
          <AccordionTrigger>
            Can I change my billing plan?
          </AccordionTrigger>
          <AccordionContent>
            You can change your plan anytime in Billing; changes apply immediately and are prorated automatically.
          </AccordionContent>
        </AccordionItem>
        <AccordionItem value="notes">
          <AccordionTrigger>
            Where can I find the release notes?
          </AccordionTrigger>
          <AccordionContent>
            Release notes are published on this page and in the changelog at the start of each week.
          </AccordionContent>
        </AccordionItem>
        <AccordionItem value="trial">
          <AccordionTrigger>
            Is there a free trial available?
          </AccordionTrigger>
          <AccordionContent>
            Yes, every new workspace includes a 14-day free trial with full access to all features.
          </AccordionContent>
        </AccordionItem>
      </Accordion>
    </div>
  )
}
```

### Settings: contained sections with metadata and status

```tsx
import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionTrigger,
} from "@/components/ui/accordion"
import { Badge } from "@/components/ui/badge"
import { cn } from "@/lib/utils"
import { Bell, CreditCard, Link2, Shield, User } from "lucide-react"
import type { ReactNode } from "react"

function Rows({
  rows,
  className,
}: {
  rows: { label: string; value: ReactNode }[]
  className?: string
}) {
  return (
    <dl className={cn("flex flex-col gap-2", className)}>
      {rows.map((row) => (
        <div
          key={row.label}
          className="flex items-center justify-between gap-4 text-sm"
        >
          <dt className="text-text-secondary">{row.label}</dt>
          <dd className="text-foreground">{row.value}</dd>
        </div>
      ))}
    </dl>
  )
}

export function SettingsExample() {
  return (
    <div className="mx-auto w-full max-w-[640px]">
      <Accordion appearance="contained" density="default" defaultValue={["billing"]}>
        <AccordionItem value="account">
          <AccordionTrigger
            icon={<User />}
            iconVariant="plain"
            meta="info@wunderui.com"
          >
            Account
          </AccordionTrigger>
          <AccordionContent>Your sign-in details and the email where notifications are sent.</AccordionContent>
        </AccordionItem>
        <AccordionItem value="billing">
          <AccordionTrigger
            icon={<CreditCard />}
            iconVariant="plain"
            meta={
              <Badge color="yellow" badgeStyle="light" shape="pill" className="h-5 px-2 text-xs">
                Action required
              </Badge>
            }
          >
            Billing
          </AccordionTrigger>
          <AccordionContent>
            <Rows
              rows={[
                { label: "Plan", value: "Team" },
                { label: "Seats", value: "12 of 15 used" },
                { label: "Renews", value: "Nov 14, 2026" },
              ]}
            />
          </AccordionContent>
        </AccordionItem>
        <AccordionItem value="notifications">
          <AccordionTrigger
            icon={<Bell />}
            iconVariant="plain"
            meta="Email and push"
          >
            Notifications
          </AccordionTrigger>
          <AccordionContent>Choose what you hear about and on which channels.</AccordionContent>
        </AccordionItem>
        <AccordionItem value="security">
          <AccordionTrigger
            icon={<Shield />}
            iconVariant="plain"
            meta={
              <Badge color="green" badgeStyle="light" shape="pill" className="h-5 px-2 text-xs">
                Verified
              </Badge>
            }
          >
            Security
          </AccordionTrigger>
          <AccordionContent>Manage your password and two-factor authentication.</AccordionContent>
        </AccordionItem>
        <AccordionItem value="apps">
          <AccordionTrigger
            icon={<Link2 />}
            iconVariant="plain"
            meta={
              <Badge color="grey" badgeStyle="light" shape="pill" className="h-5 px-2 text-xs">
                3
              </Badge>
            }
          >
            Connected apps
          </AccordionTrigger>
          <AccordionContent>Apps linked to your account and their permissions.</AccordionContent>
        </AccordionItem>
      </Accordion>
    </div>
  )
}
```

### Checkout: separated sections with an error summary and form fields

```tsx
"use client"

import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionTrigger,
} from "@/components/ui/accordion"
import { Badge } from "@/components/ui/badge"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { CircleAlert } from "lucide-react"
import { useId } from "react"

export function CheckoutExample() {
  const streetId = useId()
  const postalId = useId()
  const postalErrorId = postalId + "-error"

  return (
    <div className="mx-auto w-full max-w-[560px]">
      <Accordion appearance="separated" density="default" defaultValue={["shipping"]}>
        <AccordionItem value="contact">
          <AccordionTrigger
            meta={
              <Badge color="green" badgeStyle="light" shape="pill" className="h-5 px-2 text-xs">
                Complete
              </Badge>
            }
          >
            Contact
          </AccordionTrigger>
          <AccordionContent>Your primary contact for order updates.</AccordionContent>
        </AccordionItem>
        <AccordionItem value="shipping">
          <AccordionTrigger
            meta={
              <Badge color="red" badgeStyle="light" shape="pill" className="h-5 px-2 text-xs">
                1 error
              </Badge>
            }
          >
            Shipping address
          </AccordionTrigger>
          <AccordionContent>
            <div className="flex flex-col gap-4">
              <div className="flex flex-col gap-2">
                <Label htmlFor={streetId}>Street address</Label>
                <Input id={streetId} defaultValue="14 Garden Street" />
              </div>
              <div className="flex flex-col gap-2">
                <Label htmlFor={postalId}>Postal code</Label>
                <Input
                  id={postalId}
                  defaultValue="1011"
                  aria-invalid
                  aria-describedby={postalErrorId}
                />
                <p id={postalErrorId} className="flex items-center gap-1.5 text-xs text-tint-text-red">
                  <CircleAlert className="size-3.5" aria-hidden />
                  Postal code must have 5 digits.
                </p>
              </div>
            </div>
          </AccordionContent>
        </AccordionItem>
        <AccordionItem value="delivery">
          <AccordionTrigger meta="Standard, 3 to 5 days">
            Delivery
          </AccordionTrigger>
          <AccordionContent>Estimated delivery dates appear after checkout.</AccordionContent>
        </AccordionItem>
        <AccordionItem value="payment">
          <AccordionTrigger meta="Not started">
            Payment
          </AccordionTrigger>
          <AccordionContent>No payment method added yet.</AccordionContent>
        </AccordionItem>
      </Accordion>
    </div>
  )
}
```

### Profile: progress and error summary in divided sections

```tsx
import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionTrigger,
} from "@/components/ui/accordion"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { Circle, CircleCheck, TriangleAlert } from "lucide-react"

export function ProfileExample() {
  return (
    <div className="mx-auto w-full max-w-[560px]">
      <Accordion appearance="divided" density="default" multiple defaultValue={["profile", "address"]}>
        <AccordionItem value="profile">
          <AccordionTrigger
            meta={<span className="font-medium">3 of 5 completed</span>}
          >
            Profile
          </AccordionTrigger>
          <AccordionContent>
            <ul className="flex flex-col gap-2">
              <li className="flex items-center gap-2 text-sm">
                <CircleCheck className="size-4 text-success" aria-hidden />
                <span className="text-text-secondary">Add a profile photo</span>
              </li>
              <li className="flex items-center gap-2 text-sm">
                <CircleCheck className="size-4 text-success" aria-hidden />
                <span className="text-text-secondary">Verify your email</span>
              </li>
              <li className="flex items-center gap-2 text-sm">
                <CircleCheck className="size-4 text-success" aria-hidden />
                <span className="text-text-secondary">Set your display name</span>
              </li>
              <li className="flex items-center gap-2 text-sm">
                <Circle className="size-4 text-text-tertiary" aria-hidden />
                <span className="text-foreground">Add a phone number</span>
              </li>
              <li className="flex items-center gap-2 text-sm">
                <Circle className="size-4 text-text-tertiary" aria-hidden />
                <span className="text-foreground">Connect a calendar</span>
              </li>
            </ul>
          </AccordionContent>
        </AccordionItem>
        <AccordionItem value="address">
          <AccordionTrigger
            meta={
              <Badge color="red" badgeStyle="light" shape="pill" className="h-5 px-2 text-xs">
                2 errors
              </Badge>
            }
          >
            Address
          </AccordionTrigger>
          <AccordionContent>
            <div className="flex flex-col gap-3">
              <div className="flex items-center justify-between gap-4">
                <span className="flex items-center gap-2 text-sm text-tint-text-red">
                  <TriangleAlert className="size-4" aria-hidden />
                  Street address is required.
                </span>
                <Button variant="link" size="sm" className="min-h-6 w-fit p-0">
                  Go to field
                </Button>
              </div>
              <div className="flex items-center justify-between gap-4">
                <span className="flex items-center gap-2 text-sm text-tint-text-red">
                  <TriangleAlert className="size-4" aria-hidden />
                  Postal code must have 5 digits.
                </span>
                <Button variant="link" size="sm" className="min-h-6 w-fit p-0">
                  Go to field
                </Button>
              </div>
            </div>
          </AccordionContent>
        </AccordionItem>
        <AccordionItem value="preferences">
          <AccordionTrigger meta="Optional">
            Preferences
          </AccordionTrigger>
          <AccordionContent>
            Choose which sections appear on your public profile and who can see them.
          </AccordionContent>
        </AccordionItem>
      </Accordion>
    </div>
  )
}
```

### Inspector: compact sections in a side panel

```tsx
import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionTrigger,
} from "@/components/ui/accordion"
import { cn } from "@/lib/utils"
import { Image, Layers, SlidersHorizontal, Type, Zap } from "lucide-react"
import type { ReactNode } from "react"

function Rows({
  rows,
  className,
}: {
  rows: { label: string; value: ReactNode }[]
  className?: string
}) {
  return (
    <dl className={cn("flex flex-col gap-2", className)}>
      {rows.map((row) => (
        <div
          key={row.label}
          className="flex items-center justify-between gap-4 text-sm"
        >
          <dt className="text-text-secondary">{row.label}</dt>
          <dd className="text-foreground">{row.value}</dd>
        </div>
      ))}
    </dl>
  )
}

export function InspectorExample() {
  return (
    <div className="mx-auto w-full max-w-[280px]">
      <Accordion appearance="contained" density="compact" multiple defaultValue={["layers", "properties"]}>
        <AccordionItem value="layers">
          <AccordionTrigger icon={<Layers />} iconVariant="plain">
            Layers
          </AccordionTrigger>
          <AccordionContent>
            <Rows
              rows={[
                { label: "Header", value: "Frame" },
                { label: "Sidebar", value: "Frame" },
                { label: "Content", value: "Auto layout" },
              ]}
              className="text-xs"
            />
          </AccordionContent>
        </AccordionItem>
        <AccordionItem value="properties">
          <AccordionTrigger icon={<SlidersHorizontal />} iconVariant="plain">
            Properties
          </AccordionTrigger>
          <AccordionContent>
            <Rows
              rows={[
                { label: "Width", value: "320" },
                { label: "Height", value: "48" },
                { label: "Opacity", value: "100%" },
              ]}
              className="text-xs"
            />
          </AccordionContent>
        </AccordionItem>
        <AccordionItem value="typography">
          <AccordionTrigger icon={<Type />} iconVariant="plain">
            Typography
          </AccordionTrigger>
          <AccordionContent>Font, size and weight controls.</AccordionContent>
        </AccordionItem>
        <AccordionItem value="effects">
          <AccordionTrigger icon={<Zap />} iconVariant="plain">
            Effects
          </AccordionTrigger>
          <AccordionContent>Shadows and layer styles.</AccordionContent>
        </AccordionItem>
        <AccordionItem value="export">
          <AccordionTrigger icon={<Image />} iconVariant="plain">
            Export
          </AccordionTrigger>
          <AccordionContent>Export formats and scale.</AccordionContent>
        </AccordionItem>
      </Accordion>
    </div>
  )
}
```

### Async panel: loading, error, retry, ready

```tsx
import {
  Accordion,
  AccordionContent,
  AccordionFeedback,
  AccordionItem,
  AccordionTrigger,
} from "@/components/ui/accordion"
import { History } from "lucide-react"

export function Example() {
  return (
    <Accordion appearance="divided" density="default" defaultValue={["sync"]}>
      <AccordionItem value="sync">
        <AccordionTrigger icon={<History />} iconVariant="plain">
          Sync history
        </AccordionTrigger>
        <AccordionContent>
          <AccordionFeedback kind="loading" loadingLabel="Loading sync history…" />
        </AccordionContent>
      </AccordionItem>
    </Accordion>
  )
}
```

### Release notes: expand and collapse all

```tsx
import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionTrigger,
} from "@/components/ui/accordion"
import { Button } from "@/components/ui/button"
import { useState } from "react"

const RELEASE_NOTES = [
  { value: "v2.4", title: "Version 2.4", body: "Adds keyboard shortcuts for every section and a faster search." },
  { value: "v2.3", title: "Version 2.3", body: "Fixes a layout shift when a long title wraps onto two lines." },
  { value: "v2.2", title: "Version 2.2", body: "Improves loading states and adds retry to every panel." },
]

export function ReleaseNotesExample() {
  const [open, setOpen] = useState<string[]>(["v2.4"])

  return (
    <div className="mx-auto flex w-full max-w-[560px] flex-col gap-3">
      <div className="flex min-h-8 items-center justify-between gap-3">
        <p className="text-sm font-semibold text-foreground">Release notes</p>
        <div className="flex items-center gap-2">
          <Button
            variant="plain"
            size="sm"
            onClick={() => setOpen(RELEASE_NOTES.map((release) => release.value))}
          >
            Expand all
          </Button>
          <Button variant="plain" size="sm" onClick={() => setOpen([])}>
            Collapse all
          </Button>
        </div>
      </div>
      <Accordion appearance="contained" density="default" multiple value={open} onValueChange={setOpen}>
        {RELEASE_NOTES.map((release) => (
          <AccordionItem key={release.value} value={release.value}>
            <AccordionTrigger>{release.title}</AccordionTrigger>
            <AccordionContent>{release.body}</AccordionContent>
          </AccordionItem>
        ))}
      </Accordion>
    </div>
  )
}
```

### Selectable sections: notification categories with a switch

```tsx
"use client"

import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionRow,
  AccordionTrigger,
} from "@/components/ui/accordion"
import { Switch } from "@/components/ui/switch"
import { useState } from "react"

export function SelectableExample() {
  const [productUpdates, setProductUpdates] = useState(true)
  const [commentsMentions, setCommentsMentions] = useState(true)
  const [email, setEmail] = useState(true)
  const [push, setPush] = useState(false)
  const [billingAlerts, setBillingAlerts] = useState(false)

  return (
    <div className="mx-auto w-full max-w-[560px]">
      <Accordion appearance="contained" density="default" multiple defaultValue={["comments"]}>
        <AccordionItem value="product">
          <AccordionRow
            leading={
              <Switch
                checked={productUpdates}
                onCheckedChange={setProductUpdates}
                aria-label="Product updates notifications"
              />
            }
          >
            <AccordionTrigger description="New features and improvements">
              Product updates
            </AccordionTrigger>
          </AccordionRow>
          <AccordionContent>Tips and highlights for new capabilities.</AccordionContent>
        </AccordionItem>
        <AccordionItem value="comments">
          <AccordionRow
            leading={
              <Switch
                checked={commentsMentions}
                onCheckedChange={setCommentsMentions}
                aria-label="Comments and mentions notifications"
              />
            }
          >
            <AccordionTrigger description="Replies to your comments and @mentions">
              Comments and mentions
            </AccordionTrigger>
          </AccordionRow>
          <AccordionContent>
            <div className="flex flex-col gap-3">
              <div className="flex items-center justify-between gap-4">
                <div>
                  <p className="text-sm text-foreground">Email</p>
                  <p className="text-xs text-text-secondary">Weekly digest and mentions</p>
                </div>
                <Switch checked={email} onCheckedChange={setEmail} aria-label="Email notifications" />
              </div>
              <div className="flex items-center justify-between gap-4">
                <div>
                  <p className="text-sm text-foreground">Push</p>
                  <p className="text-xs text-text-secondary">Direct messages only</p>
                </div>
                <Switch checked={push} onCheckedChange={setPush} aria-label="Push notifications" />
              </div>
            </div>
          </AccordionContent>
        </AccordionItem>
        <AccordionItem value="billing">
          <AccordionRow
            leading={
              <Switch
                checked={billingAlerts}
                onCheckedChange={setBillingAlerts}
                aria-label="Billing alerts notifications"
              />
            }
          >
            <AccordionTrigger description="Invoices and failed payments">
              Billing alerts
            </AccordionTrigger>
          </AccordionRow>
          <AccordionContent>Important notices about your account balance.</AccordionContent>
        </AccordionItem>
      </Accordion>
    </div>
  )
}
```

### Action beside the trigger: addresses with an Edit button

```tsx
import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionRow,
  AccordionTrigger,
} from "@/components/ui/accordion"
import { Button } from "@/components/ui/button"

export function AddressesExample() {
  return (
    <div className="mx-auto w-full max-w-[560px]">
      <Accordion appearance="separated" density="default" defaultValue={["billing"]}>
        <AccordionItem value="billing">
          <AccordionRow
            action={
              <Button variant="plain" size="sm" aria-label="Edit billing address">
                Edit
              </Button>
            }
          >
            <AccordionTrigger>Billing address</AccordionTrigger>
          </AccordionRow>
          <AccordionContent>
            <div className="flex flex-col">
              <p className="font-medium text-foreground">Nora Lindgren</p>
              <p>14 Garden Street</p>
              <p>Berlin 10115</p>
              <p>Germany</p>
            </div>
          </AccordionContent>
        </AccordionItem>
        <AccordionItem value="shipping">
          <AccordionRow
            action={
              <Button variant="plain" size="sm" aria-label="Edit shipping address">
                Edit
              </Button>
            }
          >
            <AccordionTrigger description="Same as billing address">
              Shipping address
            </AccordionTrigger>
          </AccordionRow>
          <AccordionContent>Delivered to the billing address.</AccordionContent>
        </AccordionItem>
      </Accordion>
    </div>
  )
}
```

## For AI agents

`get_component("accordion")`

Hand your agent this page as Markdown or the WunderUI MCP server, not a screenshot.
