# 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).





<ComponentPreview name="accordion-demo" align="start">
  <AccordionDemo />
</ComponentPreview>

## Installation [#installation]

<Tabs defaultValue="cli">
  <TabsList>
    <TabsTrigger value="cli">
      CLI
    </TabsTrigger>

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

  <TabsContent value="cli">
    ```bash
    npx shadcn@latest add https://shadcn-cssinjs.com/r/accordion.json
    ```
  </TabsContent>

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

      ```bash
      pnpm add @base-ui/react @stylexjs/stylex
      ```

      <Step>
        Make sure [StyleX is configured](/docs/installation) and the design tokens are
        installed.
      </Step>

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

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

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

## Usage [#usage]

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

```tsx
<Accordion defaultValue={["item-1"]}>
  <AccordionItem value="item-1">
    <AccordionTrigger>Is it accessible?</AccordionTrigger>
    <AccordionContent>
      Yes. It adheres to the WAI-ARIA design pattern.
    </AccordionContent>
  </AccordionItem>
</Accordion>
```

## Composition [#composition]

Use the following composition to build an `Accordion`:

```txt
Accordion
├── AccordionItem
│   ├── AccordionTrigger
│   └── AccordionContent
└── AccordionItem
    ├── AccordionTrigger
    └── AccordionContent
```

## Examples [#examples]

### Basic [#basic]

A basic accordion that shows one item at a time. The first item is open by default.

<ComponentPreview name="accordion-basic" align="start">
  <AccordionBasic />
</ComponentPreview>

### Multiple [#multiple]

Use the `multiple` prop to allow multiple items to be open at the same time.

<ComponentPreview name="accordion-multiple" align="start">
  <AccordionMultiple />
</ComponentPreview>

### Disabled [#disabled]

Use the `disabled` prop on `AccordionItem` to disable individual items.

<ComponentPreview name="accordion-disabled" align="start">
  <AccordionDisabled />
</ComponentPreview>

### Borders [#borders]

Wrap the `Accordion` in a bordered, rounded container to group the items.

<ComponentPreview name="accordion-borders" align="start">
  <AccordionBorders />
</ComponentPreview>

### Card [#card]

Wrap the `Accordion` in a `Card` component.

<ComponentPreview name="accordion-card" align="start">
  <AccordionCard />
</ComponentPreview>



## RTL [#rtl]

To enable right-to-left support, see the [RTL guide](/docs/rtl).

<ComponentPreview name="accordion-rtl" direction="rtl">
  <AccordionRtl />
</ComponentPreview>

## API Reference [#api-reference]

See the [Base UI](https://base-ui.com/react/components/accordion#api-reference)
documentation for the full API.
