Skip to content

Collapsible

hc-collapsible is a single show/hide disclosure — a lightweight, link-styled “show more” toggle for one region. It is pure CSS over the native <details> / <summary> elements: the browser owns the keyboard handling and the open state; no JavaScript.

Show details

This region is hidden until the user opens it. It is great for secondary details, advanced options, or a long “read more” passage that would otherwise crowd the page.

Add the open attribute to <details> to have it start expanded.

PartPurpose
.hc-collapsibleThe <details> element (add open to expand).
.hc-collapsible__triggerThe <summary> — the clickable toggle.
.hc-collapsible__iconThe chevron; rotates 180° when open.
.hc-collapsible__contentThe revealed region.

When open or closed the region animates its height — pure CSS, no JavaScript — via ::details-content with interpolate-size: allow-keywords (so the height can transition to and from auto). The chevron rotation and the height both respect prefers-reduced-motion: reduce.

  • <details> / <summary> give you the right semantics for free: the summary is a button that toggles aria-expanded, is keyboard operable (Enter / Space), and is in the tab order — no ARIA to add.
  • Keep the chevron decorative (aria-hidden="true"); the summary text is the accessible name, so write it as a clear action (“Show details”).
  • The content stays in the DOM when collapsed, so in-page search (and find links) still reach it where the engine supports the height animation.
Token pathPurpose
collapsible.trigger.gapGap between label and chevron.
collapsible.trigger.padding-x / -yTrigger padding.
collapsible.trigger.font-weightTrigger weight.
collapsible.trigger.fg / hover-fgTrigger (link) color.
collapsible.icon.sizeChevron size.
collapsible.icon.transition-durationChevron rotation speed.
collapsible.content.fgRevealed text color.
collapsible.content.padding-block-startGap below the trigger.
collapsible.content.transition-durationHeight animation speed.
Show the generated CSS variables
--hc-collapsible-trigger-gap | -trigger-padding-x | -trigger-padding-y
--hc-collapsible-trigger-font-weight | -trigger-fg | -trigger-hover-fg
--hc-collapsible-icon-size | -icon-transition-duration
--hc-collapsible-content-fg | -content-padding-block-start
--hc-collapsible-content-transition-duration
  • Accordion — a group of collapsible sections with an optional exclusive mode.
  • Card — a common container for a collapsible block of secondary detail.