Skip to main content
  1. Docs
  2. Components
  3. Navigation

Accordion

Sections that fold, ruled between. Each title is a heading and a button.

Import
@qeetrix/react
Status
StableSince 0.0.2
Renders
<h3><button>Server-rendered
Tested
WCAG 2.2 AAaxe on every pull request

01

Import

accordion.tsx
// From the package: a build keeps only what it uses.
import { Accordion, AccordionItem } from "@qeetrix/react";

// Or from its own path.
import { Accordion, AccordionItem } from "@qeetrix/react/accordion";

02

Props

And every native attribute of the element it renders.

PropTypeDefaultWhat it does
value · defaultValuestring[][]The open sections' values: an array, even when only one can be open.
onValueChange(value[], details) => void—Called with the open sections' values.
multiplebooleanfalseLet several be open; otherwise opening one closes the other.
disabledbooleanfalseEvery section stays as it is.
AccordionItem: titleReactNoderequiredThe trigger's text.
AccordionItem: valuestringan idWhat value holds when it's open: set it to open or control the section.
AccordionItem: headingLevel2 – 63The heading that wraps the trigger.
AccordionItem: disabledbooleanfalseThis section doesn't open or close.

03

Parts

Each part carries a data-slot, for tests and placement.

data-slotElementWhat it is
accordion<div>The root.
accordion-item<div>data-open while open.
accordion-header<h3>The heading.
accordion-trigger<button>aria-expanded, aria-controls.
accordion-panel<div role="region">hidden="until-found" while closed.
accordion-content<div>The padded content.

04

Find in page

A closed section's text stays in the page, hidden until found: Ctrl+F opens the section that holds the match.

faq.tsx
<Accordion>
  <AccordionItem value="sso" title="Which SSO protocols are supported?">
    SAML 2.0 and OpenID Connect.
  </AccordionItem>
</Accordion>
Next — AccordionAccessibility