
# Accordion



> Accordion component organizes related content in a compact space that can be revealed and hidden.

## Examples

### Default

```tsx
import { Accordion } from "@kesko/components";

export default () => (
  <>
    <Accordion open>
      <summary>
        <h3>Delivery</h3>
      </summary>
      <p>Orders placed before noon are delivered the same day. Choose a two-hour slot at checkout.</p>
    </Accordion>
    <Accordion>
      <summary>
        <h3>Returns</h3>
      </summary>
      <p>Return unopened products within 14 days to any K-Ruoka store or through the courier.</p>
    </Accordion>
    <Accordion>
      <summary>
        <h3>Payment</h3>
      </summary>
      <p>We accept cards, MobilePay and invoice. K-Plussa points are added to every purchase.</p>
    </Accordion>
  </>
);

```

```html
<details class="k-accordion" open>
  <summary>
    <h3>Delivery</h3>
  </summary>
  <p>Orders placed before noon are delivered the same day. Choose a two-hour slot at checkout.</p>
</details>
<details class="k-accordion">
  <summary>
    <h3>Returns</h3>
  </summary>
  <p>Return unopened products within 14 days to any K-Ruoka store or through the courier.</p>
</details>
<details class="k-accordion">
  <summary>
    <h3>Payment</h3>
  </summary>
  <p>We accept cards, MobilePay and invoice. K-Plussa points are added to every purchase.</p>
</details>
```

### Controlled

```tsx
import { useState } from "react";
import { Accordion, Button, Stack } from "@kesko/components";

export default () => {
  const [open, setOpen] = useState(true);

  return (
    <Stack gap="sm">
      <Button appearance="outline" onClick={() => setOpen(value => !value)}>
        {open ? "Collapse" : "Expand"}
      </Button>
      <Accordion open={open} onToggle={event => setOpen(event.currentTarget.open)}>
        <summary>
          <h3>Delivery</h3>
        </summary>
        <p>Orders placed before noon are delivered the same day. Choose a two-hour slot at checkout.</p>
      </Accordion>
    </Stack>
  );
};

```

```html
<k-stack gap="sm">
  <button class="k-button" appearance="outline">Collapse</button>
  <details class="k-accordion" open>
    <summary>
      <h3>Delivery</h3>
    </summary>
    <p>Orders placed before noon are delivered the same day. Choose a two-hour slot at checkout.</p>
  </details>
</k-stack>
```

### Disabled

```tsx
import { Accordion } from "@kesko/components";

export default () => (
  <Accordion disabled>
    <summary>
      <h3>Delivery</h3>
    </summary>
    <p>Orders placed before noon are delivered the same day. Choose a two-hour slot at checkout.</p>
  </Accordion>
);

```

```html
<details class="k-accordion" disabled>
  <summary aria-disabled="true" tabindex="-1">
    <h3>Delivery</h3>
  </summary>
  <p>Orders placed before noon are delivered the same day. Choose a two-hour slot at checkout.</p>
</details>
```

### Exclusive group

```tsx
import { Accordion } from "@kesko/components";

export default () => (
  <>
    <Accordion name="faq" open>
      <summary>
        <h3>Delivery</h3>
      </summary>
      <p>Orders placed before noon are delivered the same day. Choose a two-hour slot at checkout.</p>
    </Accordion>
    <Accordion name="faq">
      <summary>
        <h3>Returns</h3>
      </summary>
      <p>Return unopened products within 14 days to any K-Ruoka store or through the courier.</p>
    </Accordion>
    <Accordion name="faq">
      <summary>
        <h3>Payment</h3>
      </summary>
      <p>We accept cards, MobilePay and invoice. K-Plussa points are added to every purchase.</p>
    </Accordion>
  </>
);

```

```html
<details class="k-accordion" name="faq" open>
  <summary>
    <h3>Delivery</h3>
  </summary>
  <p>Orders placed before noon are delivered the same day. Choose a two-hour slot at checkout.</p>
</details>
<details class="k-accordion" name="faq">
  <summary>
    <h3>Returns</h3>
  </summary>
  <p>Return unopened products within 14 days to any K-Ruoka store or through the courier.</p>
</details>
<details class="k-accordion" name="faq">
  <summary>
    <h3>Payment</h3>
  </summary>
  <p>We accept cards, MobilePay and invoice. K-Plussa points are added to every purchase.</p>
</details>
```

### Panel

```tsx
import { Accordion, Stack } from "@kesko/components";

export default () => (
  <Stack gap="sm">
    <Accordion variant="panel" open>
      <summary>
        <h3>Delivery</h3>
      </summary>
      <p>Orders placed before noon are delivered the same day. Choose a two-hour slot at checkout.</p>
    </Accordion>
    <Accordion variant="panel">
      <summary>
        <h3>Returns</h3>
      </summary>
      <p>Return unopened products within 14 days to any K-Ruoka store or through the courier.</p>
    </Accordion>
    <Accordion variant="panel">
      <summary>
        <h3>Payment</h3>
      </summary>
      <p>We accept cards, MobilePay and invoice. K-Plussa points are added to every purchase.</p>
    </Accordion>
  </Stack>
);

```

```html
<k-stack gap="sm">
  <details class="k-accordion" variant="panel" open>
    <summary>
      <h3>Delivery</h3>
    </summary>
    <p>Orders placed before noon are delivered the same day. Choose a two-hour slot at checkout.</p>
  </details>
  <details class="k-accordion" variant="panel">
    <summary>
      <h3>Returns</h3>
    </summary>
    <p>Return unopened products within 14 days to any K-Ruoka store or through the courier.</p>
  </details>
  <details class="k-accordion" variant="panel">
    <summary>
      <h3>Payment</h3>
    </summary>
    <p>We accept cards, MobilePay and invoice. K-Plussa points are added to every purchase.</p>
  </details>
</k-stack>
```

### Sizes

```tsx
import { Accordion, Stack } from "@kesko/components";

export default () => (
  <Stack gap="lg" alignment="stretch">
    <Stack gap="2xs">
      <span className="k-text-sm">Medium</span>
      <Accordion variant="panel" open>
        <summary>
          <h3>Basic information</h3>
        </summary>
        <p>Registered in September 2026 with 4 000 km on the clock, located at K-Auto Tampere.</p>
      </Accordion>
    </Stack>
    <Stack gap="2xs">
      <span className="k-text-sm">Small</span>
      <Accordion variant="panel" size="sm" open>
        <summary>
          <h3>Basic information</h3>
        </summary>
        <p>Registered in September 2026 with 4 000 km on the clock, located at K-Auto Tampere.</p>
      </Accordion>
    </Stack>
  </Stack>
);

```

```html
<k-stack gap="lg" alignment="stretch">
  <k-stack gap="2xs">
    <span class="k-text-sm">Medium</span>
    <details class="k-accordion" variant="panel" open>
      <summary>
        <h3>Basic information</h3>
      </summary>
      <p>Registered in September 2026 with 4 000 km on the clock, located at K-Auto Tampere.</p>
    </details>
  </k-stack>
  <k-stack gap="2xs">
    <span class="k-text-sm">Small</span>
    <details class="k-accordion k-accordion-sm" variant="panel" open>
      <summary>
        <h3>Basic information</h3>
      </summary>
      <p>Registered in September 2026 with 4 000 km on the clock, located at K-Auto Tampere.</p>
    </details>
  </k-stack>
</k-stack>
```

### With content

```tsx
import { Accordion, Button } from "@kesko/components";

export default () => (
  <Accordion size="sm" lang="fi" open style={{ "--k-accordion-text": "var(--k-color-text-base)" }}>
    <summary>
      <h3>Miksi toisin autoni valtuutettuun merkkihuoltoon?</h3>
    </summary>
    <p>
      Valtuutettu merkkihuolto tarkoittaa huoltoa, jonka autonvalmistaja on hyväksynyt. Huollossa käytetään valmistajan
      määrittelemiä huoltomenetelmiä, ohjelmistoja ja alkuperäisiä varaosia, ja huolto kirjautuu auton viralliseen
      huoltohistoriaan.
    </p>
    <p>
      Huollattamalla autosi merkkihuollossa varmistatkin, että autosi huolletaan aina valmistajan tuoreimpien ohjeiden
      ja vaatimusten mukaisesti. Merkkihuollossa käytetään vain valmistajan hyväksymiä työkaluja, työtapoja ja
      varaosia.
    </p>
    <p>Kun olet myymässä autoasi, merkkihuollon leima huoltokirjassa kertoo, että autosta on pidetty asianmukaista huolta.</p>
    <Button href="https://www.k-auto.fi/huolto/">Varaa huolto</Button>
  </Accordion>
);

```

```html
<details class="k-accordion k-accordion-sm" lang="fi" open style="--k-accordion-text: var(--k-color-text-base)">
  <summary>
    <h3>Miksi toisin autoni valtuutettuun merkkihuoltoon?</h3>
  </summary>
  <p>
    Valtuutettu merkkihuolto tarkoittaa huoltoa, jonka autonvalmistaja on hyväksynyt. Huollossa käytetään valmistajan määrittelemiä huoltomenetelmiä, ohjelmistoja ja alkuperäisiä varaosia, ja huolto kirjautuu auton viralliseen huoltohistoriaan.
  </p>
  <p>
    Huollattamalla autosi merkkihuollossa varmistatkin, että autosi huolletaan aina valmistajan tuoreimpien ohjeiden ja vaatimusten mukaisesti. Merkkihuollossa käytetään vain valmistajan hyväksymiä työkaluja, työtapoja ja varaosia.
  </p>
  <p>Kun olet myymässä autoasi, merkkihuollon leima huoltokirjassa kertoo, että autosta on pidetty asianmukaista huolta.</p>
  <a class="k-button" href="https://www.k-auto.fi/huolto/">Varaa huolto</a>
</details>
```

### With icon and badge

```tsx
import { Accordion, Badge } from "@kesko/components";
import { IconHeart } from "@kesko/iconography/react";

export default () => (
  <Accordion open>
    <summary>
      <h3>
        <IconHeart /> Favourites
      </h3>
      <Badge>4</Badge>
    </summary>
    <p>Salted butter, oat milk, rye bread and coffee are on your favourites list.</p>
  </Accordion>
);

```

```html
<details class="k-accordion" open>
  <summary>
    <h3><svg viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M20.852 4.673c-2.432-2.265-6.365-2.153-8.767.25l-.083.082-.082-.082c-2.402-2.403-6.338-2.515-8.768-.25C.595 7.053.52 11.196 2.99 13.667l8.307 8.31c.39.39 1.025.39 1.415 0l8.308-8.307c2.471-2.471 2.396-6.615-.163-8.995zm-.897 7.937L12 20.565 4.045 12.61c-1.881-1.881-1.816-5.027.125-6.84 1.845-1.72 4.845-1.625 6.685.215l.862.863c.155.155.41.155.565 0l.863-.863c1.84-1.837 4.837-1.935 6.685-.215 1.941 1.809 2.007 4.96.125 6.837z" fill="currentColor" /></svg> Favourites</h3>
    <k-badge>4</k-badge>
  </summary>
  <p>Salted butter, oat milk, rye bread and coffee are on your favourites list.</p>
</details>
```

### With table

```tsx
import { Accordion } from "@kesko/components";

const rows = [
  ["Registration number", "ABC-123"],
  ["First registration", "11.9.2026"],
  ["Mileage", "4 000 km"],
  ["Colour", "Grey"],
  ["Location", "K-Auto Tampere"],
  ["Body type", "SUV"],
  ["Transmission", "Automatic"],
];

export default () => (
  <Accordion variant="panel" open>
    <summary>
      <h3>Basic information</h3>
    </summary>
    <table style={{ inlineSize: "100%", borderCollapse: "collapse" }}>
      <tbody>
        {rows.map(([label, value]) => (
          <tr key={label} className="k-border-b k-border-divider">
            <th scope="row" className="k-py-sm" style={{ textAlign: "start", fontWeight: "normal" }}>
              {label}
            </th>
            <td className="k-py-sm">
              <strong>{value}</strong>
            </td>
          </tr>
        ))}
      </tbody>
    </table>
  </Accordion>
);

```

```html
<details class="k-accordion" variant="panel" open>
  <summary>
    <h3>Basic information</h3>
  </summary>
  <table style="inline-size: 100%; border-collapse: collapse">
    <tbody>
      <tr class="k-border-b k-border-divider">
        <th scope="row" class="k-py-sm" style="text-align: start; font-weight: normal">Registration number</th>
        <td class="k-py-sm"><strong>ABC-123</strong></td>
      </tr>
      <tr class="k-border-b k-border-divider">
        <th scope="row" class="k-py-sm" style="text-align: start; font-weight: normal">First registration</th>
        <td class="k-py-sm"><strong>11.9.2026</strong></td>
      </tr>
      <tr class="k-border-b k-border-divider">
        <th scope="row" class="k-py-sm" style="text-align: start; font-weight: normal">Mileage</th>
        <td class="k-py-sm"><strong>4 000 km</strong></td>
      </tr>
      <tr class="k-border-b k-border-divider">
        <th scope="row" class="k-py-sm" style="text-align: start; font-weight: normal">Colour</th>
        <td class="k-py-sm"><strong>Grey</strong></td>
      </tr>
      <tr class="k-border-b k-border-divider">
        <th scope="row" class="k-py-sm" style="text-align: start; font-weight: normal">Location</th>
        <td class="k-py-sm"><strong>K-Auto Tampere</strong></td>
      </tr>
      <tr class="k-border-b k-border-divider">
        <th scope="row" class="k-py-sm" style="text-align: start; font-weight: normal">Body type</th>
        <td class="k-py-sm"><strong>SUV</strong></td>
      </tr>
      <tr class="k-border-b k-border-divider">
        <th scope="row" class="k-py-sm" style="text-align: start; font-weight: normal">Transmission</th>
        <td class="k-py-sm"><strong>Automatic</strong></td>
      </tr>
    </tbody>
  </table>
</details>
```


## Props

- `variant` — `"plain" | "panel"` (default: `"plain"`) The style variant of the accordion.
- `size` — `"sm" | "md"` (default: `"md"`) The size of the accordion.
- `open` — `boolean` Whether the panel is expanded. Pair it with `onToggle` to control via state.
- `disabled` — `boolean` Disables the component. The summary stays visible but is marked `aria-disabled` and leaves the tab order.
- `name` — `string` Accordions that share a `name` are exclusive: opening one closes the others.

## Events

- `onToggle` — `(event: SyntheticEvent<HTMLDetailsElement>) => void` Called after the panel has opened or closed. Read `event.currentTarget.open` for the new state.

## CSS custom properties

- `--k-accordion-radius` (default: `var(--k-radius-panel)`) Overrides the border radius of the panel variant.
- `--k-accordion-bg` (default: `transparent`) Overrides the background color. The panel variant defaults to `var(--k-color-bg-surface)`.
- `--k-accordion-border` (default: `var(--k-color-border-divider)`) Overrides the divider color. The panel variant defaults to `transparent`.
- `--k-accordion-text` (default: `var(--k-color-text-primary)`) Overrides the title color. The chevron keeps the primary color of the variant.

## Accessibility

Accordion is built on a native `<details>` element with `<summary>` as the trigger, so the browser provides the button role, the expanded state and Enter and Space activation.

- **Put a heading in the summary.** Every level from `h1` to `h6` looks the same, so pick the one that follows the heading above the accordion. Some screen readers announce the summary as a button only, which is why the words have to work without the heading semantics.
- **Say what the panel holds.** Screen readers read the `<summary>` as the name of the trigger: a leading icon is skipped, and a [Badge](/components/badge/) count is read as part of it. “Favourites, 4” works; an icon with no words doesn’t.
- **Keep controls out of the summary.** A link or a button inside it competes with the trigger. Put actions in the panel.
- **Disable sparingly.** `disabled` keeps the title readable, marks the summary `aria-disabled` and takes it out of the tab order. In plain HTML the summary also needs `aria-disabled="true"` and `tabindex="-1"`, and a script that focuses it can still toggle it. If the content is simply unavailable, leave the accordion out instead.
- **Group with `name` only for optional content.** Accordions sharing a `name` close each other without moving focus. Do not use that for steps a person has to complete in order.
- **Do not hide what people must see.** A closed panel is not announced. Required inputs and error messages belong outside the accordion.
- **Check contrast if you override colors.** `--k-accordion-text` needs 4.5:1 against `--k-accordion-bg`. Verify with the [WebAIM contrast checker](https://webaim.org/resources/contrastchecker/).

See the [accessibility guidelines](/accessibility/) and the [A11Y checklist](/a11y-checklist/) for more details.

## Integration

Install `@kesko/components` together with `@kesko/css`, which provides the design tokens and base styles it depends on, and `@kesko/themes` for your brand:

```sh
npm install @kesko/components @kesko/css @kesko/themes
```

Then load the base stylesheet and one brand theme once, in your app's entry point or root layout. Leave out `@kesko/css/components`: it mirrors the component styles for plain HTML, and `@kesko/components` already ships them.

```tsx
import "@kesko/css";
import "@kesko/themes/dist/k-rauta.css";
```

Finally, import the component into your project:

```tsx
import { Accordion } from "@kesko/components";
```

Projects without React get the same markup and styling from `@kesko/css` by importing the base stylesheet, the `components` add-on and a brand theme, in that order:

```css
@import "@kesko/css";
@import "@kesko/css/components";
@import "@kesko/themes/dist/k-rauta.css";
```

The HTML examples above show the exact markup to copy.

## Resources

- [Usage guidelines](/components/usage/) — Learn how to use the component library with React, Next.js, or basic HTML.
- [Localization](/localization/) — How to translate the components for multiple languages.
- [CSS Framework](/css/) — Utilities and tokens for everything the components don’t cover.
- [Themes](/themes/) — How to customize the component library theme.
- [Accessibility checklist](/a11y-checklist/) — Interactive, browser-based Kesko accessibility checklist.

