Accordion

A stack of collapsible panels where the open item rises as a soft chip.

Basic

Each .accordion__item carries data-state="open|closed": a closed item sits transparent on the frame, an open one fills with a surface chip and reveals its body. The toggling — the measured height transition and single-open coordination — comes from the @stisla/vanilla layer via data-stisla-accordion on the root and data-stisla-accordion-trigger on each button. Multiple items may stay open at once. The demos below are live: click a header to expand it.

Keyboard

Each .accordion__trigger is a native <button>, so the browser handles focus and activation.

KeyAction
TabMove focus to the next trigger, or out of the accordion
Shift + TabMove focus backward
Enter / SpaceToggle the focused panel

Single open

Add data-stisla-accordion-type="single" on the root to enforce one-open-at-a-time. Opening any trigger closes the others.

Seamless in a card

Add .accordion--seamless to drop the outer frame so the accordion sits edge-to-edge inside a card or page. Items lose their chip inset and a single divider sits between rows.

With leading icon

Drop an icon inside the trigger before the label. The chevron stays pinned to the end.

Disabled item

A native disabled on the trigger fades it and blocks the toggle.

Events

stisla:accordion:value-change fires on the accordion root after a successful open or close. The detail object carries the freshly-changed item under value, the prior selection under previousValue, and the full set of currently-open items under openItems. Use it to sync URL hash state, persist the last-open item, or react to user navigation through the panels.

Customization

These variables retune the stack. Override on the root or any wrapper.

VariableUse
--accordion-gapSpace between items
--accordion-padding-block / -padding-inlineFrame inset; also feeds the concentric item radius
--accordion-bgFrame background
--accordion-border-color / -border-widthFrame rim
--accordion-radius / -shadowFrame corner radius and elevation
--accordion-item-open-bg / -item-open-border-colorOpen chip fill and rim
--accordion-trigger-padding-block / -padding-inlineTrigger interior padding
--accordion-trigger-font-size / -font-weightTrigger label type
--accordion-trigger-color / -bg / -bg-hoverTrigger text, fill, and closed-item hover
--accordion-trigger-divider-colorLine under an open trigger
--accordion-ringFocus outline color
--accordion-icon-size / -icon-color / -icon-transition-durationChevron size, color, and rotation timing
--accordion-body-colorBody text color
--accordion-body-padding-block / -padding-inlineBody interior padding