# Accordion

Reveal sections of related content with keyboard-accessible headings.

Reveal sections of related content with keyboard-accessible headings.

<p className="zenos-base-ui-source">
  Backed by <a href="https://base-ui.com/react/components/accordion">Base UI Accordion</a> for
  upstream behavior and configuration. Zenos owns the public API, styling, and composition shown on
  this page.
</p>

```tsx
import { Accordion, Stack, Text } from "@zentara-co/zenos-ui";

const accordionPreviewItems = [
  {
    value: "notifications",
    title: "Notification settings",
    body: "Manage email alerts and push notifications for workspace updates.",
  },
  {
    value: "privacy",
    title: "Privacy & security",
    body: "Review sign-in methods, sessions, and data sharing preferences.",
  },
] as const;

function AccordionPreviewExample() {
  return (
    <Stack
      direction="row"
      gap="6"
      wrap="wrap"
      align="start"
      className="w-full max-w-4xl justify-center"
    >
      {(["default", "plain"] as const).map((variant) => (
        <Stack key={variant} gap="2" className="min-w-72 flex-1">
          <Text size="s" className="font-medium capitalize text-text-subtle">
            {variant}
          </Text>
          <Accordion.Root
            variant={variant}
            defaultValue={[accordionPreviewItems[0].value]}
            className="w-full"
          >
            {accordionPreviewItems.map((item) => (
              <Accordion.Item key={`${variant}-${item.value}`} value={item.value}>
                <Accordion.Header>
                  <Accordion.Trigger>{item.title}</Accordion.Trigger>
                </Accordion.Header>
                <Accordion.Content>{item.body}</Accordion.Content>
              </Accordion.Item>
            ))}
          </Accordion.Root>
        </Stack>
      ))}
    </Stack>
  );
}
```

## Anatomy

Each item needs a unique `value`. Wrap the trigger in `Header` so the disclosure control keeps proper heading semantics.

```tsx
<Accordion.Root defaultValue={["billing"]}>
  <Accordion.Item value="billing">
    <Accordion.Header>
      <Accordion.Trigger>Billing</Accordion.Trigger>
    </Accordion.Header>
    <Accordion.Content>Invoices and payment methods.</Accordion.Content>
  </Accordion.Item>
</Accordion.Root>
```

`Root` uses the same neutral card surface, border, and radius as [Collapsible](/components/collapsible/) when `variant="default"`. `Trigger` matches Collapsible interaction states (hover, open, focus ring, chevron). `Content` animates height and renders a top divider with padded body text in `text-text-subtle`.

## Variants

`variant="default"` is the contained card used in settings panels and docs previews. `variant="plain"` removes the outer border and fill so the accordion sits flush on the page background—only horizontal dividers separate items, triggers have no hover fill, and content flows directly under the title without an inner divider. The preview at the top compares both side by side.

## Import

```tsx
import { Accordion } from "@zentara-co/zenos-ui";
```

## Single and multiple expansion

By default, opening one item closes the others. Pass `multiple` when several sections may stay open, such as notification and session settings on the same page.

```tsx
import { Accordion } from "@zentara-co/zenos-ui";

function AccordionMultipleExample() {
  return (
    <Accordion.Root
      multiple
      defaultValue={["notifications", "sessions"]}
      className="w-full max-w-xl"
    >
      <Accordion.Item value="notifications">
        <Accordion.Header>
          <Accordion.Trigger>Notifications</Accordion.Trigger>
        </Accordion.Header>
        <Accordion.Content>Choose which workspace events send notifications.</Accordion.Content>
      </Accordion.Item>
      <Accordion.Item value="sessions">
        <Accordion.Header>
          <Accordion.Trigger>Active sessions</Accordion.Trigger>
        </Accordion.Header>
        <Accordion.Content>Review devices currently signed in to this account.</Accordion.Content>
      </Accordion.Item>
      <Accordion.Item value="recovery">
        <Accordion.Header>
          <Accordion.Trigger>Recovery options</Accordion.Trigger>
        </Accordion.Header>
        <Accordion.Content>Configure backup codes and recovery contacts.</Accordion.Content>
      </Accordion.Item>
    </Accordion.Root>
  );
}
```

Control expansion with `value` and `onValueChange`, or use `defaultValue` for uncontrolled usage. Values are string arrays even when only one panel is open.

## Disabled item

Disable an item when its content is unavailable. The trigger stays visible; Base UI sets `aria-disabled` and blocks activation.

```tsx
import { Accordion } from "@zentara-co/zenos-ui";

function AccordionDisabledExample() {
  return (
    <Accordion.Root className="w-full max-w-xl">
      <Accordion.Item value="available">
        <Accordion.Header>
          <Accordion.Trigger>Available setting</Accordion.Trigger>
        </Accordion.Header>
        <Accordion.Content>This setting is available to all workspace owners.</Accordion.Content>
      </Accordion.Item>
      <Accordion.Item value="locked" disabled>
        <Accordion.Header>
          <Accordion.Trigger>Enterprise setting</Accordion.Trigger>
        </Accordion.Header>
        <Accordion.Content>This setting requires the Enterprise plan.</Accordion.Content>
      </Accordion.Item>
    </Accordion.Root>
  );
}
```

## Accordion or Collapsible

Use Accordion for a related set of labeled sections where heading structure and choosing among panels matters. Use [Collapsible](/components/collapsible/) for a single optional region such as advanced settings or secondary metadata.

## Styling and composition

Default parts provide the design-system surface, chevron, dividers between items, and content spacing. Use `showChevron={false}` when another indicator shows state. Apply `contentClassName` on the inner wrapper so custom styling does not affect the animated panel height.

```tsx
import { Accordion } from "@zentara-co/zenos-ui";

function AccordionCustomExample() {
  return (
    <Accordion.Root
      defaultValue={["campaign"]}
      className="max-w-xl border-border-accent-teal-default bg-background-accent-teal-subtlest-default"
    >
      <Accordion.Item value="campaign" className="border-border-accent-teal-default">
        <Accordion.Header>
          <Accordion.Trigger className="text-text-accent-teal-bolder hover:bg-background-accent-teal-subtlest-hover data-[panel-open]:bg-background-accent-teal-subtlest-hover">
            Campaign settings
          </Accordion.Trigger>
        </Accordion.Header>
        <Accordion.Content contentClassName="border-border-accent-teal-default text-text-accent-teal-bolder">
          Audiences, budgets, and scheduling for the current quarter.
        </Accordion.Content>
      </Accordion.Item>
      <Accordion.Item value="exports" className="border-border-accent-teal-default">
        <Accordion.Header>
          <Accordion.Trigger className="text-text-accent-teal-bolder hover:bg-background-accent-teal-subtlest-hover data-[panel-open]:bg-background-accent-teal-subtlest-hover">
            Export defaults
          </Accordion.Trigger>
        </Accordion.Header>
        <Accordion.Content contentClassName="border-border-accent-teal-default text-text-accent-teal-bolder">
          CSV and JSON export formats for workspace reports.
        </Accordion.Content>
      </Accordion.Item>
    </Accordion.Root>
  );
}
```

Pass `className` on `Root` or `Item` to tint the surface and borders. Style `Trigger` hover and open fills the same way as Collapsible. `Trigger` supports Base UI's `render` prop when a specialized element must own the control—keep a clear accessible name and visible expanded state.

## Variants

default, plain

## Anatomy

```text
Accordion.Root
Accordion.Item
Accordion.Header
Accordion.Trigger
Accordion.Content
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| Root.variant | default \| plain | default | Default uses a bordered card surface; plain is a flat list with horizontal dividers only. |
| value | string[] | — | Controlled expanded items. |
| defaultValue | string[] | — | Initial uncontrolled expanded items. |
| onValueChange | (value: string[]) => void | — | Runs when expansion changes. |
| multiple | boolean | false | Allows multiple open items. |
| disabled (Item / Trigger) | boolean | false | Disables an item and its trigger. |
| Trigger.showChevron | boolean | true | Shows the built-in disclosure chevron. |
| Content.contentClassName | string | — | Classes on the inner content wrapper; panel height animation is unchanged. |
| Root.className | string | — | Merged on the root. Uses bg-background-neutral-card by default, matching Collapsible. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

## Accessibility

Triggers expose button semantics with `aria-expanded`. Enter and Space toggle the focused section; arrow keys move between triggers in the group. Keep trigger labels concise and unique. Disabled items expose `aria-disabled`. Motion-reduction preferences disable height and chevron transitions.

Source: https://zenos-ui.pages.dev/components/accordion/