An accordion is a vertically stacked set of interactive headings containing a title, content snippet, or thumbnail representing a section of content. ## Resources [Latest version: v1.35.2](https://www.npmjs.com/package/@zag-js/accordion) [Logic Visualizer](https://zag-visualizer.vercel.app/accordion) [Source Code](https://github.com/chakra-ui/zag/tree/main/packages/machines/accordion) **Features** - Full keyboard navigation - Supports single and multiple expanded items - Supports collapsible items - Supports horizontal and vertical orientation ## Installation Install the accordion package: ```bash npm install @zag-js/accordion @zag-js/svelte # or yarn add @zag-js/accordion @zag-js/svelte ``` ## Anatomy Check the accordion anatomy and part names. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Usage Import the accordion package: ```jsx import * as accordion from "@zag-js/accordion" ``` The accordion package exports two key functions: - `machine` - State machine logic. - `connect` - Maps machine state to JSX props and event handlers. > Pass a unique `id` to `useMachine` so generated element ids stay predictable. Then use the framework integration helpers: ```svelte
| {day.narrow} | {/each}
|---|
|
{value.day}
|
{/each}
|
{month.label}
|
{/each}
|
{year.label}
|
{/each}
| Wk | )} {api.weekDays.map((day, i) => ({day.narrow} | ))}
|---|---|
| {api.getWeekNumber(week)} | )} {week.map((value, i) => (
{value.day}
|
))}
Make changes to your profile here. Click save when you are done.