---
title: "Accordion"
description: "A stack of collapsible sections; one or several can be open."
category: "Layout & Navigation"
slug: accordion
url: /components/accordion
since: "0.1.0"
status: "stable"
---

# Accordion

A stack of collapsible sections; one or several can be open.

## Import

```svelte
import { Accordion, AccordionItem } from '@elluzion/iv-ui';
```

## Preview

Opening one section closes the previous one.

```svelte
<script lang="ts">
	import { Accordion, AccordionItem } from '@elluzion/iv-ui';
</script>

<Accordion defaultValue="runtime">
	<AccordionItem value="runtime" title="Runtime">
		<p>Node 22 on Linux, with the edge cache in front of every request.</p>
	</AccordionItem>
	<AccordionItem value="build" title="Build">
		<p>Static output is prerendered; the rest is bundled on demand.</p>
	</AccordionItem>
	<AccordionItem value="regions" title="Regions">
		<p>Three regions, one primary and two read replicas.</p>
	</AccordionItem>
</Accordion>
```

## Usage

- Each `AccordionItem` needs a unique `value`; the parent tracks the open values.
- Set `multiple` to keep several panels open at once.
- Bind `value` for controlled state, or use `defaultValue` for an uncontrolled accordion.

## Examples

### Multiple

`multiple` keeps every opened section open.

```svelte
<script lang="ts">
	import { Accordion, AccordionItem } from '@elluzion/iv-ui';
</script>

<Accordion multiple defaultValue={['runtime', 'regions']}>
	<AccordionItem value="runtime" title="Runtime">
		<p>Node 22 on Linux, with the edge cache in front of every request.</p>
	</AccordionItem>
	<AccordionItem value="build" title="Build">
		<p>Static output is prerendered; the rest is bundled on demand.</p>
	</AccordionItem>
	<AccordionItem value="regions" title="Regions">
		<p>Three regions, one primary and two read replicas.</p>
	</AccordionItem>
</Accordion>
```

### Custom trigger

The `trigger` snippet replaces the title content.

```svelte
<script lang="ts">
	import { IconShieldLock } from '@tabler/icons-svelte';
	import { Accordion, AccordionItem } from '@elluzion/iv-ui';
</script>

<Accordion defaultValue="access">
	<AccordionItem value="access">
		{#snippet trigger()}
			<span class="trigger">
				<IconShieldLock size={14} />
				Access control
			</span>
		{/snippet}
		<p>Roles are inherited from the organization; overrides live on the project.</p>
	</AccordionItem>
	<AccordionItem value="audit" title="Audit log">
		<p>Every privileged action is recorded with the actor and the request id.</p>
	</AccordionItem>
</Accordion>

<style>
	.trigger {
		display: inline-flex;
		align-items: center;
		gap: var(--iv_spacing-sm);
	}
</style>
```

### Accordion

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `multiple` | `boolean` | `false` | Allows several items to stay open at once. |
| `value` **bindable** | `AccordionValue` | — | Open item value(s). Bind with `bind:value` for controlled state. |
| `defaultValue` | `AccordionValue` | — | Item(s) open on first render. |
| `disabled` | `boolean` | `false` | Disables interaction and applies the disabled treatment. |
| `className` | `string` | `''` | Extra classes merged onto the root element. |

`class`, `id`, `style`, `aria-*`, and `data-*` are forwarded through rest props.

### Events — Accordion

| Event | Handler type | Description |
| --- | --- | --- |
| `change` | `(e: CustomEvent<{ value: AccordionValue }>) => void` | Called with `{ value }` after an item opens or closes. |

The legacy `on:name` form is accepted for every event.

### Snippets — Accordion

| Snippet | Type | Description |
| --- | --- | --- |
| `children` | `Snippet` | Content rendered inside the component. |

### Types — Accordion

#### `AccordionValue`

One open item, or several when `multiple` is set.

```ts
type AccordionValue = string | string[];
```

### Tokens used

`--iv_border` · `--iv_radius`

See the [token reference](/foundations/tokens.md) for values.

### CSS hooks

`.iv-accordion` · `.iv-disabled`
### AccordionItem

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` **required** | `string` | — | Unique value used by the parent accordion to track this item. |
| `title` | `string` | `''` | Trigger text. Use the `trigger` snippet for custom content. |
| `disabled` | `boolean` | `false` | Disables interaction and applies the disabled treatment. |

### Snippets — AccordionItem

| Snippet | Type | Description |
| --- | --- | --- |
| `children` | `Snippet` | Panel content revealed when the item is open. |
| `trigger` | `Snippet` | Custom trigger content replacing the title. |

### Tokens used

`--iv_border` · `--iv_disabled-opacity` · `--iv_ease-out` · `--iv_font-ui` · `--iv_foreground` · `--iv_foreground-dim` · `--iv_leading-base` · `--iv_outline-width` · `--iv_spacing-lg` · `--iv_spacing-xl` · `--iv_surface-overlay` · `--iv_surface-raised` · `--iv_text-body` · `--iv_text-btn` · `--iv_transition-fast`

See the [token reference](/foundations/tokens.md) for values.

### CSS hooks

`.iv-chevron` · `.iv-disabled` · `.iv-item` · `.iv-open` · `.iv-panel` · `.iv-trigger` · `.iv-trigger-label`

## Accessibility

| Keys | Action |
| --- | --- |
| `Tab` | Moves focus to the next trigger. |
| `Enter / Space` | Opens or closes the focused section. |

- Triggers are native buttons with `aria-expanded` and `aria-controls`.
- Panels use `role="region"` and are labelled by their trigger.
- Opening and closing respects `prefers-reduced-motion`.

## Related

- [Collapsible](/components/collapsible.md)
- [Tabs](/components/tabs.md)
- [Card](/components/card.md)
- [Separator](/components/separator.md)