# Accordion (``) > Collapsible content panels with single or multiple open items, animated height transitions, and keyboard navigation. - **Kind:** controller - **Category:** layout - **Inherits:** `Controller`, `Base` ## Attributes | Attribute | Type | Default | From | Description | | --- | --- | --- | --- | --- | | `multiple` | `boolean` | `false` | — | Allows several panels to stay open at once; otherwise opening one closes the others. | | `no-collapsible` | `boolean` | `false` | — | Keeps at least one panel open: the last open panel cannot be closed, and the first enabled panel opens automatically. | | `active` | `string` | — | — | Open panels as a comma- or space-separated list of indices, values, or ids; `-1` closes all. Kept in sync with the open state. | | `duration` | `number` | `150` | — | Panel transition duration in milliseconds; `0` disables animation. | | `no-animation` | `boolean` | `false` | — | Skips panel transitions entirely, showing and hiding content instantly. | | `targets` | `string` | `''` | — | CSS selector for item elements within the container, replacing the default item detection. | | `trigger` | `string` | `''` | — | CSS selector for the clickable trigger within each item, replacing `.z-accordion-title` detection. | | `content` | `string` | `''` | — | CSS selector for the collapsible panel within each item, replacing `.z-accordion-content` detection. | ### Inherited from `Base` | Attribute | Type | Default | From | Description | | --- | --- | --- | --- | --- | | `cls` | `string` | `''` | `Base` | Adds classes to named parts as `key: classes` pairs; a plain string targets the default part. | | `stl` | `string` | `''` | `Base` | Adds inline styles to named parts as `key: styles` pairs; a plain string targets the default part. | ## Styling Parts (`cls` / `stl`) Default `cls` target: `open`. Default `stl` target: `host-inner`. | Key | Default class | cls | stl | Description | | --- | --- | --- | --- | --- | | `open` | `z-open` | ✓ | — | Class applied to open items; the default `cls` target for this component. | ## CSS Variables | Variable | Default | Scope | Affects | Description | | --- | --- | --- | --- | --- | | `--z-accordion-border` | `var(--z-border)` | `.z-accordion` | `border-color` | Border color of the accordion items. | | `--z-accordion-border-o` | `var(--z-border-o)` | `.z-accordion` | `border-color` | Opacity applied to the item border color. | | `--z-accordion-border-style` | `solid` | `.z-accordion > li, .z-accordion > div` | `border-style` | Border style of each item. | | `--z-accordion-border-w` | `0 0 1px 0` | `.z-accordion > li, .z-accordion > div` | `border-width` | Border widths per side of each item; the default draws only a bottom hairline. | | `--z-accordion-transition` | `150ms cubic-bezier(0.16, 1, 0.3, 1)` | `.z-accordion` | `transition` | Transition timing used for the accordion's animated state changes. | | `--z-disabled-opacity` | `0.5` | `.z-accordion > .z-disabled > .z-accordion-title, .z-accordion-title.z-disabled, .z-accordion-title:disabled` | `opacity` | Opacity of disabled triggers. | ## Events | Event | Cancelable | Detail | Description | | --- | --- | --- | --- | | `z-accordion:before-hide` | ✓ | `{ index: number; item: HTMLElement; trigger: HTMLElement; content: HTMLElement; value: string }` | Fires before a panel closes; `preventDefault()` cancels the change. | | `z-accordion:before-show` | ✓ | `{ index: number; item: HTMLElement; trigger: HTMLElement; content: HTMLElement; value: string }` | Fires before a panel opens; `preventDefault()` cancels the change. | | `z-accordion:change` | — | `{ activeIndices: number[]; index: number; open: boolean; item: HTMLElement \| null; trigger: HTMLElement \| null; content: HTMLElement \| null; value: string \| null }` | Fires after any open-state change; detail carries the active indices and the primarily affected item. | | `z-accordion:hidden` | — | `{ index: number; item: HTMLElement; trigger: HTMLElement; content: HTMLElement; value: string }` | Fires after a panel's close transition completes. | | `z-accordion:hide` | — | `{ index: number; item: HTMLElement; trigger: HTMLElement; content: HTMLElement; value: string }` | Fires when a panel starts closing. | | `z-accordion:mount` | — | `Record` | Fires when deferred template content is mounted into the container. | | `z-accordion:show` | — | `{ index: number; item: HTMLElement; trigger: HTMLElement; content: HTMLElement; value: string }` | Fires when a panel starts opening. | | `z-accordion:shown` | — | `{ index: number; item: HTMLElement; trigger: HTMLElement; content: HTMLElement; value: string }` | Fires after a panel's open transition completes. | ## Methods | Method | Params | Returns | Description | | --- | --- | --- | --- | | `activeIndices()` | — | `number[]` | Returns the indices of open panels, sorted ascending. | | `close()` | `target: number \| string`, `animate?: boolean = true` | `Promise` | Closes the given panel; refuses to close the last one when `no-collapsible` is set. | | `closeAll()` | `animate?: boolean = true` | `Promise` | Closes all panels, keeping one open when `no-collapsible` is set. | | `open()` | `target: number \| string`, `animate?: boolean = true` | `Promise` | Opens the panel at the given index, value, or id; resolves `true` when open. | | `openAll()` | `animate?: boolean = true` | `Promise` | Opens every enabled panel; with `multiple` off, opens only the first enabled one. | | `refresh()` | — | `void` | Re-scans the DOM and rebinds listeners after items change. | | `toggle()` | `target: number \| string`, `animate?: boolean = true` | `Promise` | Opens the given panel if closed, otherwise closes it. | ## Data Hooks | Attribute | Values | Applies to | Role | Description | | --- | --- | --- | --- | --- | | `data-accordion-ignore` | — | `descendant` | `config` | Excludes the element from item detection. | | `data-accordion-item` | `close-all`, `next`, `open-all`, `previous` | `descendant` | `trigger` | Turns the element into an accordion control: `open-all`, `close-all`, `next`, `previous`, or a target index, value, or id to toggle. | | `data-fn` | `template` | `descendant` | `config` | Marks a deferred `