- Docs
- Components
- 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
// 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.
| Prop | Type | Default | What it does |
|---|---|---|---|
value · defaultValue | string[] | [] | The open sections' values: an array, even when only one can be open. |
onValueChange | (value[], details) => void | — | Called with the open sections' values. |
multiple | boolean | false | Let several be open; otherwise opening one closes the other. |
disabled | boolean | false | Every section stays as it is. |
AccordionItem: title | ReactNode | required | The trigger's text. |
AccordionItem: value | string | an id | What value holds when it's open: set it to open or control the section. |
AccordionItem: headingLevel | 2 – 6 | 3 | The heading that wraps the trigger. |
AccordionItem: disabled | boolean | false | This section doesn't open or close. |
03
Parts
Each part carries a data-slot, for tests and placement.
| data-slot | Element | What 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.
<Accordion>
<AccordionItem value="sso" title="Which SSO protocols are supported?">
SAML 2.0 and OpenID Connect.
</AccordionItem>
</Accordion>