Skip to content

Accordion

A list of collapsible sections that coordinate with each other. By default, only one opens at a time; with data-ts-multiple, several can be open. Each item (data-ts-accordion-item) declares its data-ts-value.

Content · TaishoDS Core, in plain HTML.

Examples

One working example per case. Each example is the HTML of its preview—copy it as is, and with Core’s CSS and JS loaded, it looks and works the same.

FAQ with one panel open

What’s included in the Pro plan?
Unlimited deployments for your team.
How do I invite someone?
From Members, with the Admin, Editor, or Viewer role.
html

When to use

  • There are several sibling sections, read one at a time, like FAQs or specifications.
  • Showing them all open would make the page overwhelming.
  • Opening one should close the previous one to keep focus.

When not to use

  • It’s a single section that opens and closes on its own → collapsible.
  • They’re alternate views of the same object → tabs.
  • The content needs to be read in full and in order. Leave it visible.

Do

  • Write titles that say what’s inside. They’re the only thing visible when collapsed.
  • Leave the first section open if it’s one almost everyone will open.

Don’t

  • Don’t hide essential information in it. Collapsed content gets read far less.
  • Don’t nest accordions.

TaishoDS Core

Needs Core’s JS, which hooks in through data-ts-* attributes.

Each item is a <details> with its <summary>, so the browser opens and closes it—by click and by keyboard—even when JavaScript doesn’t load. Core only adds the rest: opening one closes the others, the event, and opening from code.

Core hooks into it through these attributes. They go in the markup, and there’s nothing to initialize.

  • data-ts-accordion
  • data-ts-accordion-item
  • data-ts-accordion-trigger
  • data-ts-value

What it does: Without JavaScript, each item opens and closes on its own (Enter and Space on the <summary>) and several can be open at once. With Core, without data-ts-multiple opening one closes the other, and every change fires a cancelable ts:change. To open or close from code, change the <details> open property. Core follows it and that change doesn’t fire ts:change. A disabled item carries aria-disabled="true" on the <summary>; without JavaScript it still opens.

From the CDN, without a build, load taisho.accordion.css along with taisho.base.css. Also load:

  • taisho.collapsible.css
  • taisho.icon.css

For how Core works in general, see Behavior.

Accessibility

Implements the Accordion pattern from the WAI-ARIA APG.

  • Each item is a <details> and its trigger a <summary>. The browser exposes it as an expandable button and publishes the open or closed state, with no aria-expanded of its own.
  • It works the same without JavaScript: Enter and Space open and close the focused item.

Keyboard

On top of what the browser already does (Tab moves focus, Enter activates a button).

Key What it does
Enter/SpaceOpens or closes the focused section.

Verification

What was actually tested. Anything that wasn’t tested says so—we’d rather say “not verified” than claim too much.

  • axe WCAG 2.2 A + AA in a real browser, in light and dark mode, before every release.
  • keyboard Key map documented above, checked against the component.
  • screen reader Not verified with a screen reader. Test it in your own combination of components, not just here, where each one appears alone and on its happy path.