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

Open in new tab
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>
  </>
);
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>
  );
};
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>
);
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>
  </>
);
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>
);
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>
);
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>
);
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>
);
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>
);

Properties #

NameDescriptionTypeDefault
variant

The style variant of the accordion.

"plain" | "panel""plain"
size

The size of the accordion.

"sm" | "md""md"
open

Whether the panel is expanded. Pair it with onToggle to control via state.

boolean—
disabled

Disables the component. The summary stays visible but is marked aria-disabled and leaves the tab order.

boolean—
name

Accordions that share a name are exclusive: opening one closes the others.

string—

Events #

NameDescriptionType
onToggle

Called after the panel has opened or closed. Read event.currentTarget.open for the new state.

(event: SyntheticEvent<HTMLDetailsElement>) => void

Styles #

CSS custom properties provide finer-grained control than properties. See Styling API for more details. Prefer the Properties API when it suits your need.

NameDescriptionDefault
--k-accordion-radius

Overrides the border radius of the panel variant.

var(--k-radius-panel)
--k-accordion-bg

Overrides the background color. The panel variant defaults to var(--k-color-bg-surface).

transparent
--k-accordion-border

Overrides the divider color. The panel variant defaults to transparent.

var(--k-color-border-divider)
--k-accordion-text

Overrides the title color. The chevron keeps the primary color of the variant.

var(--k-color-text-primary)

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 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.

See the accessibility guidelines and the A11Y checklist for more details.


Usage #

There are two necessary parts to using the Accordion component. The @kesko/components package and the CSS Framework are required. Everything else is optional:

npm install @kesko/components @kesko/css

Once installed, load the CSS Framework in your app’s entry point or root layout:

import "@kesko/css";

Then, you can import the Accordion:

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

Projects without React can get the same styles from @kesko/css by importing the components stylesheet as well:

@import "@kesko/css";
@import "@kesko/css/components";

Resources #