5

Accordion

Collapsible content sections using the native <details> and <summary> elements.

Works with

Card
Surface to group the items on

Standalone

<link rel="stylesheet" href="https://esm.sh/@erikt/ui/accordion.css" />

Default

What is @erikt/ui?

@erikt/ui is a minimal CSS design system that styles native HTML elements directly, with no utility classes or component wrappers.

<details>
  <summary>What is @erikt/ui?</summary>
  <div>
    @erikt/ui is a minimal CSS design system that styles native HTML elements
    directly.
  </div>
</details>

Multiple items

Stack several <details> elements and they space themselves.

Getting started
Import @erikt/ui and start writing HTML.
Customization
Override CSS custom properties to match your brand.
Dark mode
@erikt/ui responds to prefers-color-scheme automatically.
<details>
  <summary>Getting started</summary>
  <div>...</div>
</details>
<details>
  <summary>Customization</summary>
  <div>...</div>
</details>
<details>
  <summary>Dark mode</summary>
  <div>...</div>
</details>

Exclusive

Give a group the same name attribute and only one item stays open at a time.

Getting started
Import @erikt/ui and start writing HTML.
Customization
Override CSS custom properties to match your brand.
Dark mode
@erikt/ui responds to prefers-color-scheme automatically.
<details name="faq">
  <summary>Getting started</summary>
  <div>...</div>
</details>
<details name="faq">
  <summary>Customization</summary>
  <div>...</div>
</details>
<details name="faq">
  <summary>Dark mode</summary>
  <div>...</div>
</details>

Open by default

Add the open attribute to expand an item on load.

This one is open
Use the open attribute to expand by default.
<details open>
  <summary>This one is open</summary>
  <div>Use the open attribute to expand by default.</div>
</details>

In a card

Put the items inside a Card to group them on their own surface.

Getting started
Import @erikt/ui and start writing HTML.
Customization
Override CSS custom properties to match your brand.
Dark mode
@erikt/ui responds to prefers-color-scheme automatically.
<article class="card secondary">
  <details name="faq">
    <summary>Getting started</summary>
    <div>...</div>
  </details>
  <details name="faq">
    <summary>Customization</summary>
    <div>...</div>
  </details>
  <details name="faq">
    <summary>Dark mode</summary>
    <div>...</div>
  </details>
</article>

API reference

Type Classes / attributes What it does
State [open] Starts expanded

Search 5021 icons

Type a name to find icons from the Tabler icon set.

      Move Open Esc Close