# Accordion

Disclosure groups on the native `<details>` element.

Source: https://www.zazz.sh/api/primitives/accordion/

## Installation

```bash
pnpm dlx zazz-ui add accordion
```

Run `zazz-ui init` first if the project has no `zazz/` folder yet.

## Examples

### Default

```html
<ui-accordion>
  <details
    style="
      --py: 4;
      --border-b: 1;
    "
  >
    <summary
      style="
        --font-weight: strong;
        --text: currentColor;
        --text--hover: var(--color-muted-foreground);
      "
    >
      What is an accordion?
      <svg data-accordion-slot="marker" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
        <rect width="256" height="256" fill="none" />
        <polyline
          points="208 96 128 176 48 96"
          fill="none"
          stroke="currentColor"
          stroke-linecap="round"
          stroke-linejoin="round"
          stroke-width="16"
        />
      </svg>
    </summary>
    <div style="--pb: 4">
      <p>
        A disclosure widget built from the native <code>&lt;details&gt;</code> and
        <code>&lt;summary&gt;</code> elements. The open/close animation uses the
        <code>::details-content</code> pseudo-element — no JavaScript.
      </p>
    </div>
  </details>
  <details
    style="
      --py: 4;
      --border-b: 1;
    "
  >
    <summary
      style="
        --font-weight: strong;
        --text: currentColor;
        --text--hover: var(--color-muted-foreground);
      "
    >
      How does it work?
      <svg data-accordion-slot="marker" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
        <rect width="256" height="256" fill="none" />
        <polyline
          points="208 96 128 176 48 96"
          fill="none"
          stroke="currentColor"
          stroke-linecap="round"
          stroke-linejoin="round"
          stroke-width="16"
        />
      </svg>
    </summary>
    <div style="--pb: 4">
      <p>
        Each item is a separate <code>&lt;details&gt;</code>, so several can stay open at once.
        Click a summary or focus it and press Enter to toggle.
      </p>
    </div>
  </details>
  <details
    style="
      --py: 4;
      --border-b: 1;
    "
  >
    <summary
      style="
        --font-weight: strong;
        --text: currentColor;
        --text--hover: var(--color-muted-foreground);
      "
    >
      Why use it?
      <svg data-accordion-slot="marker" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
        <rect width="256" height="256" fill="none" />
        <polyline
          points="208 96 128 176 48 96"
          fill="none"
          stroke="currentColor"
          stroke-linecap="round"
          stroke-linejoin="round"
          stroke-width="16"
        />
      </svg>
    </summary>
    <div style="--pb: 4">
      <p>
        Keyboard support, state, and accessibility come from the platform — Zazz only styles the
        chrome through theme tokens.
      </p>
    </div>
  </details>
</ui-accordion>
```

## Attributes

| Attribute | Kind | Values |
| --- | --- | --- |
| `data-ui="accordion"` | identity | free value |
| `<ui-accordion>` | tag | free value |
| `data-accordion-slot` | slot | `marker` |

## Hooks

| Hook | Default | State |
| --- | --- | --- |
| `--ui-accordion-display` | `flex` | — |
| `--ui-accordion-flex` | `1` | — |
| `--ui-accordion-flex-direction` | `column` | — |
| `--ui-accordion-icon-size` | `calc(var(--spacing) * 4)` | — |
| `--ui-accordion-icon-transform--open` | `rotate(-180deg)` | open |
| `--ui-accordion-item-display` | `flex` | — |
| `--ui-accordion-item-flex` | `1 0 auto` | — |
| `--ui-accordion-item-flex-direction` | `column` | — |
| `--ui-accordion-summary-display` | `flex` | — |
| `--ui-accordion-summary-items` | `center` | — |
| `--ui-accordion-summary-justify` | `space-between` | — |
| `--ui-accordion-summary-min-h` | `0` | — |
| `--ui-accordion-w` | `100%` | — |
