Skip to main content

  • Foundations
    • Border radius
    • Breakpoints
    • Colours
    • Colour scheme
    • Elevation
    • Focus and outline
    • Sizing and spacing
    • Layout
    • Motion
    • Typography
    • Z-index
  • Elements
    • Buttons
    • Code
    • Icons
    • Figure and caption
    • Forms
    • Links
    • Lists
    • Media
    • Tables
  • Components
    • Accordion
    • Alerts
    • Avatar
    • Blockquote
    • Breadcrumbs
    • Card
    • Chiplets
    • Details and summary
    • Dialog
    • Empty state
    • Stats
    • Global footer
    • Horizontal rule
    • Kanban
    • Key-value list
    • Meter
    • Objects
    • Pagination
    • Polka background
    • Post-it note
    • Progress
    • Speech bubbles
    • Status dot
    • Skeleton
    • Skip link
    • Spinner
    • Toggles
    • Tooltip
    • Webmentions
  • Patterns
    • Article header
    • Author card
    • App list and app sheet
    • Error page
    • Related posts
    • Search results
    • Utilities

John Peart

  • Search
  • Menu
John Peart

Accordion

Grouped disclosure panels built on <details>.

A set of disclosure panels built from native <details>. Browsers handle the keyboard and open-state for free — no JavaScript needed.

Multiple open

Wrap several <details> together. Any number can be open at once.

What is this site built with?

Eleventy, a pinch of Lightning CSS, and no client-side JavaScript frameworks.

How are the styles organised?

Each component has its own CSS file in engine/styles/components/, and styles.css stitches them together with @import.

Why hard-offset shadows?

They suit the illustrated, flat aesthetic and avoid the soft-blur look common to most sites.

<details>
  <summary>Question</summary>
  <p>Answer.</p>
</details>
<details>
  <summary>Another question</summary>
  <p>Another answer.</p>
</details>

Exclusive

Give each <details> the same name attribute to make them mutually exclusive — opening one closes the others. Supported in all modern browsers.

Only one open at a time

Try opening the next one — this one will close.

Click me instead

And now the first panel has closed.

Or me

Only one panel can be open at a time.

<details name="faq">
  <summary>Question 1</summary>
  <p>Answer.</p>
</details>
<details name="faq">
  <summary>Question 2</summary>
  <p>Answer.</p>
</details>

Accessibility

The <summary> is focusable and toggles on Enter or Space. Screen readers announce the expanded state automatically. See also Details & summary for the underlying styles.

A line drawing of John Peart

John Peart

www.johnpe.art

Mastodon logo

Mastodon

BlueSky logo

Bluesky

LinkedIn logo

LinkedIn

Github logo

GitHub