Skip to the page
Tactile UI

Kit part · Accordions

Collapsible

One section that opens in place. A square key sits at the start of its head with a printed chevron; opening latches the key below the plate and turns the chevron down, and the text slides out under the head on a grid row that grows from nothing, so it is never given a height of its own. It is a native details element, so it works with no script.

Element
<details class="tui-collapsible">
Needs
kit.css + kit.mjs
Rules
collapsible.rules.md · 6
Finishes
Aluminium · Graphite · Oak · Walnut · Porcelain · Black · Daylight · Night · Paper · Phosphor · E-paper · AMOLED
Volumes
Tactile · Quiet
On this page
  1. Variants
  2. Every state, at once
  3. API
  4. Markup
  5. Accessibility
  6. How it’s built
  7. Rules
  8. Related parts

Seats open in 11 days. Want one email that morning?

Variants

Advanced options

Exports run in the background now, and the settings page loads in half the time.

Closed
Advanced options

Exports run in the background now, and the settings page loads in half the time.

Open
Attachments 4 files

Quarterly letter.pdf, Map.png, Notes.txt and Sketch.png.

With a count at the end
Delivery notes

Leave with the neighbour at number 14 if nobody answers.

On a plate · .tui-collapsible--plate
A head that is a good deal longer than the row it sits in, so it wraps under its key 2

Exports run in the background now, and the settings page loads in half the time.

Long head wraps

Every state, at once

Both finishes, side by side. Hover, pressed and focus are forced with .is-hover, .is-down and .is-focus; checked and disabled are real.

Aluminium

PartClosedHoverPressingOpenFocus
Head
Section

Text.

Section

Text.

Section

Text.

Section

Text.

Section

Text.

Graphite

PartClosedHoverPressingOpenFocus
Head
Section

Text.

Section

Text.

Section

Text.

Section

Text.

Section

Text.

API

NameKindValuesWhat it does
details.tui-collapsibleelementopen attributeOne section. Add open to start it open. A plain details with no name, so opening it never closes another one.
summary > .tui-collapsible__key + __title (+ __meta)elementin this orderThe head. The key is aria-hidden; the title is the section’s name; the meta is a count or a small fact at the end.
.tui-collapsible__body > .tui-collapsible__innerelementtwo boxesThe text, in its own grid row so it can grow from 0fr to 1fr. Put the content in the inner box and give neither of them a height.
--platemodifiertui-collapsible--plateThe section on a plate of its own, for one that stands apart on a page.
toggleCollapsible(details, open?)functionneeds kit.mjsOpens, closes or flips one from code, easing the close like a press does.
toggleeventnativeFires from the details element after it has opened or, for a close, after the text has slid away.
Enter · Spacekeyon the headThe browser’s own: flips the section.

Markup

<!-- One section. The key is drawn, so it is hidden from a screen reader; the head says the state. -->
<details class="tui-collapsible">
  <summary>
    <span class="tui-collapsible__key" aria-hidden="true"></span>
    <span class="tui-collapsible__title">What changed in 4.2</span>
    <span class="tui-collapsible__meta">3 changes</span>
  </summary>
  <div class="tui-collapsible__body">
    <div class="tui-collapsible__inner">
      <p>Exports run in the background now.</p>
    </div>
  </div>
</details>
import { toggleCollapsible } from '/kit/kit.mjs';

// Opens or closes one from code, easing the close as a press does.
toggleCollapsible(document.querySelector('.tui-collapsible'));      // flip it
toggleCollapsible(details, true);                                   // open it

details.addEventListener('toggle', () => save(details.open));       // native, fires after the close is done

Needs kit.css and kit.mjs. How to install the kit.

Accessibility

  • It is a <details> with a <summary>, so a screen reader says “Release notes, collapsed” or “expanded” and the keyboard works with no script and no ARIA.
  • The chevron and the key are drawn and hidden from a screen reader, since the head already says the state; the state is also told by the key sitting lower with its chevron turned, so it is not colour.
  • Closed text is not in the page for a screen reader or the Tab key, because the browser takes it out, and while it slides away it cannot be pressed.
  • Focus is a 2px ring round the whole head. On a phone the head is at least 48px tall and the key grows to 28px, and the whole row is the press.
  • Under reduced motion the key and the chevron do not move between states, the text arrives and leaves at once, and nothing is left out.

How it’s built

The head is the accordion’s: a summary that is a row, with the same cap on a skirt that latches below the plate. The key is a separate little box so the chevron on it can turn on its own as the key sinks. The text is a grid whose one row grows from 0fr to 1fr when the section opens; closing runs the same row back with a transition, held by the script for the 200ms it takes before the details element is allowed to hide it.

Rules

collapsible.rules.mdIn the brain

Fold away one section of a page behind a square key: release notes, advanced options, a long note. The accordion’s single-row cousin.

6 rules in this file, with the foundations they rest on and the anti-patterns that break them. Full rules ship in the brain with the Pass.

Tariff

Three rates a day.

Reserve

Kept for a power cut.

Accordion

Printed sections that open in place. Each head ends in a small square key printed +; open, the key latches below the plate and reads −.

Output

Panel

A face plate that groups what belongs together: a head, a rule, then the parts. Screws only on device-like panels.

Key

Every button, and every link that acts like one: a cap on a skirt that drops below the plate when pressed.