> For AI agents: the complete documentation index is available at https://wallarm.github.io/design-system/llms.txt, the full documentation bundle is available at https://wallarm.github.io/design-system/llms-full.txt.

# Accordion

Stacks sections behind their own headers and opens each on demand — reach for `Tabs` when a few primary sections get switched between often, and leave content on the page when people read most of it anyway. `primary` and `secondary` are inline rows for grouping; `section` is the bordered panel, and the only variant with room for `AccordionActions`.

[Source](https://github.com/wallarm/design-system/tree/main/packages/design-system/src/components/Accordion) · [Storybook](https://wallarm.github.io/design-system/storybook/?path=/docs/data-display-accordion--overview)

```tsx
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@wallarm-org/design-system/Accordion';
import { Text } from '@wallarm-org/design-system/Text';

export const Primary = () => (
  <div className='w-440'>
    <Accordion variant='primary' data-testid='accordion-primary'>
      <AccordionItem value='1'>
        <AccordionTrigger>Title</AccordionTrigger>
        <AccordionContent>
          <Text>{sampleText}</Text>
        </AccordionContent>
      </AccordionItem>
      <AccordionItem value='2'>
        <AccordionTrigger>Title</AccordionTrigger>
        <AccordionContent>
          <Text>{sampleText}</Text>
        </AccordionContent>
      </AccordionItem>
    </Accordion>
  </div>
);
```

## Usage

```tsx
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@wallarm-org/design-system/Accordion';
import { Text } from '@wallarm-org/design-system/Text';
```

## Examples

### Secondary

A 24px row in small medium-weight muted type with no hover fill, for dense or
nested groups where the header should sit behind the content it labels.

```tsx
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@wallarm-org/design-system/Accordion';
import { Text } from '@wallarm-org/design-system/Text';

export const Secondary = () => (
  <div className='w-440'>
    <Accordion variant='secondary' data-testid='accordion-secondary'>
      <AccordionItem value='1'>
        <AccordionTrigger>Title</AccordionTrigger>
        <AccordionContent>
          <Text>{sampleText}</Text>
        </AccordionContent>
      </AccordionItem>
      <AccordionItem value='2'>
        <AccordionTrigger>Title</AccordionTrigger>
        <AccordionContent>
          <Text>{sampleText}</Text>
        </AccordionContent>
      </AccordionItem>
    </Accordion>
  </div>
);
```

### Section

`section` draws each item as a bordered panel row — title left, chevron right —
and the title takes inline content, here a `NumericBadge` carrying a count.

```tsx
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@wallarm-org/design-system/Accordion';
import { NumericBadge } from '@wallarm-org/design-system/NumericBadge';
import { Text } from '@wallarm-org/design-system/Text';

export const Section = () => (
  <div className='w-440'>
    <Accordion variant='section' defaultValue={['1']} data-testid='accordion-section'>
      <AccordionItem value='1'>
        <AccordionTrigger>
          Title <NumericBadge>2</NumericBadge>
        </AccordionTrigger>
        <AccordionContent>
          <Text>{sampleText}</Text>
        </AccordionContent>
      </AccordionItem>
      <AccordionItem value='2'>
        <AccordionTrigger>
          Title <NumericBadge>2</NumericBadge>
        </AccordionTrigger>
        <AccordionContent>
          <Text>{sampleText}</Text>
        </AccordionContent>
      </AccordionItem>
    </Accordion>
  </div>
);
```

### Section with actions

`AccordionActions` renders beside the trigger rather than inside it, so buttons in
the header act on the section without toggling it open.

```tsx
import { Accordion, AccordionActions, AccordionContent, AccordionItem, AccordionTrigger } from '@wallarm-org/design-system/Accordion';
import { Button } from '@wallarm-org/design-system/Button';
import { NumericBadge } from '@wallarm-org/design-system/NumericBadge';
import { Text } from '@wallarm-org/design-system/Text';

export const SectionWithActions = () => (
  <div className='w-560'>
    <Accordion
      variant='section'
      defaultValue={['1']}
      data-testid='accordion-section-actions'
    >
      <AccordionItem value='1'>
        <AccordionTrigger>
          Title <NumericBadge>2</NumericBadge>
        </AccordionTrigger>
        <AccordionActions>
          <Button variant='ghost' size='small'>
            Delete
          </Button>
          <Button variant='outline' size='small'>
            Edit
          </Button>
        </AccordionActions>
        <AccordionContent>
          <Text>{sampleText}</Text>
        </AccordionContent>
      </AccordionItem>
      <AccordionItem value='2'>
        <AccordionTrigger>
          Title <NumericBadge>2</NumericBadge>
        </AccordionTrigger>
        <AccordionActions>
          <Button variant='ghost' size='small'>
            Delete
          </Button>
          <Button variant='outline' size='small'>
            Edit
          </Button>
        </AccordionActions>
        <AccordionContent>
          <Text>{sampleText}</Text>
        </AccordionContent>
      </AccordionItem>
    </Accordion>
  </div>
);
```

### Long title primary

Titles truncate to one line rather than wrapping — the row is a fixed height, so
reword a long header instead of relying on the ellipsis.

```tsx
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@wallarm-org/design-system/Accordion';
import { Text } from '@wallarm-org/design-system/Text';

export const LongTitlePrimary = () => (
  <div className='w-320'>
    <Accordion variant='primary' data-testid='accordion-long-title-primary'>
      <AccordionItem value='1'>
        <AccordionTrigger>{longTitleText}</AccordionTrigger>
        <AccordionContent>
          <Text>{sampleText}</Text>
        </AccordionContent>
      </AccordionItem>
    </Accordion>
  </div>
);
```

### Long title secondary

The same 320px column at `secondary` size, where smaller type and no row padding
leave a little more of the title visible before the ellipsis.

```tsx
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@wallarm-org/design-system/Accordion';
import { Text } from '@wallarm-org/design-system/Text';

export const LongTitleSecondary = () => (
  <div className='w-320'>
    <Accordion variant='secondary' data-testid='accordion-long-title-secondary'>
      <AccordionItem value='1'>
        <AccordionTrigger>{longTitleText}</AccordionTrigger>
        <AccordionContent>
          <Text>{sampleText}</Text>
        </AccordionContent>
      </AccordionItem>
    </Accordion>
  </div>
);
```

### Multiple

`multiple` keeps several sections open at once, for when people reference sections
on their own terms — not when the sections have to be read side by side, which is
a layout rather than an accordion.

```tsx
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@wallarm-org/design-system/Accordion';
import { Text } from '@wallarm-org/design-system/Text';

export const Multiple = () => (
  <div className='w-440'>
    <Accordion
      variant='section'
      multiple
      defaultValue={['1', '2']}
      data-testid='accordion-multiple'
    >
      <AccordionItem value='1'>
        <AccordionTrigger>Section A</AccordionTrigger>
        <AccordionContent>
          <Text>{sampleText}</Text>
        </AccordionContent>
      </AccordionItem>
      <AccordionItem value='2'>
        <AccordionTrigger>Section B</AccordionTrigger>
        <AccordionContent>
          <Text>{sampleText}</Text>
        </AccordionContent>
      </AccordionItem>
      <AccordionItem value='3'>
        <AccordionTrigger>Section C</AccordionTrigger>
        <AccordionContent>
          <Text>{sampleText}</Text>
        </AccordionContent>
      </AccordionItem>
    </Accordion>
  </div>
);
```

### Disabled

`disabled` on a single `AccordionItem` fades the row and blocks its toggle while the
rest stay live; the same prop on `Accordion` locks every row at once.

```tsx
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@wallarm-org/design-system/Accordion';
import { Text } from '@wallarm-org/design-system/Text';

export const Disabled = () => (
  <div className='w-440'>
    <Accordion variant='primary' data-testid='accordion-disabled'>
      <AccordionItem value='1'>
        <AccordionTrigger>Available</AccordionTrigger>
        <AccordionContent>
          <Text>{sampleText}</Text>
        </AccordionContent>
      </AccordionItem>
      <AccordionItem value='2' disabled>
        <AccordionTrigger>Disabled item</AccordionTrigger>
        <AccordionContent>
          <Text>{sampleText}</Text>
        </AccordionContent>
      </AccordionItem>
    </Accordion>
  </div>
);
```

## Props

| Prop          | Type                            | Default   | Description                                                          |
| ------------- | ------------------------------- | --------- | -------------------------------------------------------------------- |
| variant       | `AccordionVariant \| undefined` | `primary` | Visual variant of the accordion                                      |
| multiple      | `boolean \| undefined`          | `false`   | Whether multiple items can be expanded at the same time              |
| collapsible   | `boolean \| undefined`          | `true`    | Whether an expanded item can be collapsed (when `multiple` is false) |
| value         | `string[] \| undefined`         |           | Controlled expanded item values                                      |
| defaultValue  | `string[] \| undefined`         |           | Initial expanded item values for uncontrolled usage                  |
| onValueChange | `complex`                       |           | Callback fired when expanded items change                            |
| disabled      | `boolean \| undefined`          |           | Disable all interaction                                              |
| data-testid   | `string \| undefined`           |           |                                                                      |

### AccordionActions

| Prop           | Type                                                 | Default | Description |
| -------------- | ---------------------------------------------------- | ------- | ----------- |
| defaultChecked | `boolean \| undefined`                               |         |             |
| defaultValue   | `string \| number \| readonly string[] \| undefined` |         |             |
| autoFocus      | `boolean \| undefined`                               |         |             |
| id             | `string \| undefined`                                |         |             |
| tabIndex       | `number \| undefined`                                |         |             |
| title          | `string \| undefined`                                |         |             |
| rel            | `string \| undefined`                                |         |             |
| onChange       | `ChangeEventHandler<T, Element> \| undefined`        |         |             |

### AccordionContent

| Prop           | Type                                                 | Default | Description                                                                                         |
| -------------- | ---------------------------------------------------- | ------- | --------------------------------------------------------------------------------------------------- |
| title          | `string \| undefined`                                |         |                                                                                                     |
| defaultChecked | `boolean \| undefined`                               |         |                                                                                                     |
| defaultValue   | `string \| number \| readonly string[] \| undefined` |         |                                                                                                     |
| autoFocus      | `boolean \| undefined`                               |         |                                                                                                     |
| id             | `string \| undefined`                                |         |                                                                                                     |
| tabIndex       | `number \| undefined`                                |         |                                                                                                     |
| rel            | `string \| undefined`                                |         |                                                                                                     |
| onChange       | `ChangeEventHandler<T, Element> \| undefined`        |         |                                                                                                     |
| asChild        | `boolean \| undefined`                               |         | Use the provided child element as the default rendered element, combining their props and behavior. |

### AccordionItem

| Prop           | Type                                                 | Default | Description                                                                                         |
| -------------- | ---------------------------------------------------- | ------- | --------------------------------------------------------------------------------------------------- |
| title          | `string \| undefined`                                |         |                                                                                                     |
| defaultChecked | `boolean \| undefined`                               |         |                                                                                                     |
| defaultValue   | `string \| number \| readonly string[] \| undefined` |         |                                                                                                     |
| autoFocus      | `boolean \| undefined`                               |         |                                                                                                     |
| id             | `string \| undefined`                                |         |                                                                                                     |
| tabIndex       | `number \| undefined`                                |         |                                                                                                     |
| rel            | `string \| undefined`                                |         |                                                                                                     |
| onChange       | `ChangeEventHandler<T, Element> \| undefined`        |         |                                                                                                     |
| value \*       | `string`                                             |         | The value of the accordion item.                                                                    |
| disabled       | `boolean \| undefined`                               |         | Whether the accordion item is disabled.                                                             |
| asChild        | `boolean \| undefined`                               |         | Use the provided child element as the default rendered element, combining their props and behavior. |

### AccordionTrigger

| Prop           | Type                                                 | Default | Description                                                                                         |
| -------------- | ---------------------------------------------------- | ------- | --------------------------------------------------------------------------------------------------- |
| title          | `string \| undefined`                                |         |                                                                                                     |
| defaultChecked | `boolean \| undefined`                               |         |                                                                                                     |
| defaultValue   | `string \| number \| readonly string[] \| undefined` |         |                                                                                                     |
| autoFocus      | `boolean \| undefined`                               |         |                                                                                                     |
| id             | `string \| undefined`                                |         |                                                                                                     |
| tabIndex       | `number \| undefined`                                |         |                                                                                                     |
| rel            | `string \| undefined`                                |         |                                                                                                     |
| onChange       | `ChangeEventHandler<T, Element> \| undefined`        |         |                                                                                                     |
| disabled       | `boolean \| undefined`                               |         |                                                                                                     |
| name           | `string \| undefined`                                |         |                                                                                                     |
| value          | `string \| number \| readonly string[] \| undefined` |         |                                                                                                     |
| asChild        | `boolean \| undefined`                               |         | Use the provided child element as the default rendered element, combining their props and behavior. |

## Explorer

