---
title: "Accordion"
description: "Sections that open and close under their headings, one at a time or independently."
---

Stacked sections that open under their headings, built on [Radix Accordion](https://www.radix-ui.com/primitives/docs/components/accordion) in React and [Reka UI Accordion](https://reka-ui.com/docs/components/accordion) in Vue. The primitive owns the behaviour; newt/ui owns the look.

Use it for content a reader wants one piece of at a time: a short FAQ, the groups of a settings page, the optional details of a form. If every section should be read, plain headings serve better than making the reader open each one.

_Live example of Accordion — see the page for the rendered demo._

## Installation

```bash
npx newtui@latest add accordion
```

npm dependencies: React: radix-ui. Vue: reka-ui.

Files written — React: components/ui/accordion.tsx. Vue: components/ui/accordion/Accordion.vue, components/ui/accordion/AccordionItem.vue, components/ui/accordion/AccordionTrigger.vue, components/ui/accordion/AccordionContent.vue, components/ui/accordion/index.ts.

## Usage

React:

```tsx
import { Accordion } from "@/components/ui/accordion"
```

Vue:

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

Give each `AccordionItem` a unique `value`. Put an `AccordionTrigger` and an `AccordionContent` inside it. To open a section at the start, pass its value to `defaultValue` on `Accordion`.

## Examples

### Multiple open

With `type="multiple"` the sections open and close independently, and `defaultValue` takes a list of values. Use it when a reader compares sections. Keep the default `single` for a list of questions.

_Live example of Accordion — see the page for the rendered demo._

### Custom title

`AccordionTrigger` takes more than text. Here each heading carries a `Badge` with a count.

_Live example of Accordion — see the page for the rendered demo._

## API reference

**`Accordion`**

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `type` | `"single" \| "multiple"` | `"single"` | `single` closes the open section when another opens. `multiple` lets them open independently. |
| `value / v-model` | `string \| string[]` | — | The open section, or the list of open sections when `type` is `multiple`. Leave it out and pass `defaultValue` to let the accordion own it. |
| `defaultValue` | `string \| string[]` | — | The section or sections that start open. |
| `onValueChange` | `(value: string \| string[]) => void` | — | React only. Called when a section opens or closes; Vue emits `update:modelValue`. |
| `collapsible` | `boolean` | `true` | Only for `single`. When `false`, a press on the open section does not close it. |
| `disabled` | `boolean` | `false` | Stops every section from opening or closing. |

**`AccordionItem`**

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `string` | — | Required. The name of the section, unique in the accordion. |
| `disabled` | `boolean` | `false` | Stops this section from opening or closing. |

`AccordionTrigger` renders a button inside an `<h3>`, followed by the chevron. `AccordionContent` renders the panel, which is removed from the page while the section is closed. Every part also accepts the native attributes of the element it renders, and a `className` that is merged rather than replaced.

## Accessibility

Each trigger is a button inside a heading and carries `aria-expanded` and `aria-controls` for its panel. The panel is a `role="region"` named by its trigger. `Enter` and `Space` toggle a section. `Tab` moves between triggers, and so do the Down and Up arrow keys, `Home` and `End`. A disabled trigger is dimmed and takes no focus. Write a title that makes sense alone, because a screen reader user moves through the titles before opening any. The chevron is decoration, turns a quarter when the section is open, and is mirrored in right-to-left text.

A closed panel is not in the page, so find-in-page does not match text inside it. In Vue, pass `:unmount-on-hide="false"` to `Accordion` to keep closed panels in the page; a find-in-page match then opens the section.

## Tokens

Accordion reads its colours, radii and motion from the `--newt-*` tokens. Override a token rather than editing the component.
