Data display
Accordion
Free4.2 KB gzippedA vertically stacked set of headings that each reveal a section of content. Follows the WAI-ARIA APG Accordion pattern: every trigger is a real <button> inside a heading, with aria-expanded and aria-controls, and each panel is labelled by its trigger.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Enter, Space, Arrow Down and 4 more · Full report
Import
import { Accordion } from "@vjdesigns/vjdesigns-ui";
Importing only Accordion adds about 4.2 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Basic
One panel open at a time. Each trigger is a heading button; arrow keys move between them.
Orders ship within one business day and arrive in 3–5 days.
import { Accordion, Text } from "@vjdesigns/vjdesigns-ui";
export function Basic() {
return (
<div style={{ width: "100%", maxWidth: "34rem" }}>
<Accordion defaultValue="shipping">
<Accordion.Item value="shipping">
<Accordion.Trigger>How long does shipping take?</Accordion.Trigger>
<Accordion.Content>
<Text tone="muted">Orders ship within one business day and arrive in 3–5 days.</Text>
</Accordion.Content>
</Accordion.Item>
<Accordion.Item value="returns">
<Accordion.Trigger>What's your return policy?</Accordion.Trigger>
<Accordion.Content>
<Text tone="muted">Return anything within 30 days for a full refund. Return shipping is free.</Text>
</Accordion.Content>
</Accordion.Item>
<Accordion.Item value="warranty">
<Accordion.Trigger>Is there a warranty?</Accordion.Trigger>
<Accordion.Content>
<Text tone="muted">Every product has a two-year warranty against defects.</Text>
</Accordion.Content>
</Accordion.Item>
</Accordion>
</div>
);
}
Multiple
type="multiple" lets several panels stay open. Triggers can carry a description and a badge.
Your profile is visible to everyone in your workspace.
import { Accordion, Badge, Text } from "@vjdesigns/vjdesigns-ui";
export function Multiple() {
return (
<div style={{ width: "100%", maxWidth: "34rem" }}>
<Accordion type="multiple" variant="contained" defaultValue={["profile"]}>
<Accordion.Item value="profile">
<Accordion.Trigger description="Name, photo and bio">Profile</Accordion.Trigger>
<Accordion.Content>
<Text tone="muted">Your profile is visible to everyone in your workspace.</Text>
</Accordion.Content>
</Accordion.Item>
<Accordion.Item value="billing">
<Accordion.Trigger description="Plan and payment method" badge={<Badge tone="warning">Action needed</Badge>}>
Billing
</Accordion.Trigger>
<Accordion.Content>
<Text tone="muted">Your card expires next month. Update it to avoid interruptions.</Text>
</Accordion.Content>
</Accordion.Item>
<Accordion.Item value="danger" disabled>
<Accordion.Trigger description="Only workspace owners can change this">Delete workspace</Accordion.Trigger>
<Accordion.Content />
</Accordion.Item>
</Accordion>
</div>
);
}
Accessibility
Each trigger is a button inside a real heading (headingLevel), so screen reader users can jump between sections by heading. Arrow keys, Home and End move between triggers, and hiddenUntilFound lets the browser's find-in-page search closed panels and open the one that matches.
Yes. Upgrades apply right away; downgrades apply at the end of the billing period.
We refund annual plans in full within 30 days of purchase.
import { Accordion, Text } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
return (
<div style={{ width: "100%", maxWidth: "34rem" }}>
<Accordion type="multiple" headingLevel={3} hiddenUntilFound>
<Accordion.Item value="plan">
<Accordion.Trigger>Can I change my plan later?</Accordion.Trigger>
<Accordion.Content>
<Text tone="muted">Yes. Upgrades apply right away; downgrades apply at the end of the billing period.</Text>
</Accordion.Content>
</Accordion.Item>
<Accordion.Item value="refund">
<Accordion.Trigger>Do you offer refunds?</Accordion.Trigger>
<Accordion.Content>
<Text tone="muted">We refund annual plans in full within 30 days of purchase.</Text>
</Accordion.Content>
</Accordion.Item>
</Accordion>
</div>
);
}
Translated
In Hebrew the accordion mirrors: the chevron moves to the left and text aligns right. The questions and answers are your own text.
ההזמנות נשלחות תוך יום עסקים אחד ומגיעות תוך 3–5 ימים.
import { Accordion, Text, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import he from "@vjdesigns/vjdesigns-ui/locales/he";
export function Translated() {
return (
<LocaleProvider locale="he" messages={he}>
<div style={{ width: "100%", maxWidth: "34rem" }}>
<Accordion defaultValue="ship">
<Accordion.Item value="ship">
<Accordion.Trigger>כמה זמן לוקח המשלוח?</Accordion.Trigger>
<Accordion.Content>
<Text tone="muted">ההזמנות נשלחות תוך יום עסקים אחד ומגיעות תוך 3–5 ימים.</Text>
</Accordion.Content>
</Accordion.Item>
<Accordion.Item value="return">
<Accordion.Trigger>מה מדיניות ההחזרות?</Accordion.Trigger>
<Accordion.Content>
<Text tone="muted">אפשר להחזיר כל מוצר תוך 30 יום.</Text>
</Accordion.Content>
</Accordion.Item>
</Accordion>
</div>
</LocaleProvider>
);
}
Usage notes
Compose with Accordion.Item, Accordion.Trigger, and Accordion.Content (also exported as AccordionItem, AccordionTrigger, AccordionContent).
API reference
Accordion
| Prop | Type | Default |
|---|---|---|
type
| "single""multiple" | "single" |
collapsibleIn | boolean | never | true |
valueControlled open item value ( | string | null | string[] | — |
defaultValueInitially open item value when uncontrolled. | string | null | string[] | null |
onValueChangeCalled with the open item value (or | (value: string | null) => void | (value: string[]) => void | — |
variantVisual style. | "separated""contained""flush" | "separated" |
sizeTrigger padding and type size. | "sm""md""lg" | "md" |
headingLevelHeading level wrapping each trigger. Choose it by the page outline; override per item. | 123456 | 3 |
iconExpand indicator: | AccordionIcon | "chevron" |
iconPositionSide of the trigger the indicator sits on. | "start""end" | "end" |
keyboardNavigationWAI-ARIA APG arrow-key navigation between triggers (ArrowUp/ArrowDown wrap, Home, End). Tab always works. | boolean | true |
regionRolePanel landmark behavior. | falsetrue"auto" | "auto" |
forceMountKeep every panel's children mounted while closed (still | boolean | false |
hiddenUntilFoundHide closed panels with | boolean | false |
disabledDisable every item. | boolean | false |
children
| ReactNode | — |
Also accepts standard HTML attributes, plus className, style and ref.
Accordion.Item
One collapsible section: a trigger and its content. Exposes data-state="open" | "closed" and data-disabled.
| Prop | Type | Default |
|---|---|---|
valueRequiredUnique value identifying this item in the accordion's | string | — |
disabledPrevent opening or closing this item. Its trigger is a disabled button and is skipped by arrow keys. | boolean | false |
headingLevelHeading level for this item's trigger, overriding the accordion's | 123456 | — |
childrenOne | ReactNode | — |
Also accepts native <div> attributes, plus className, style and ref.
Accordion.Trigger
The button that toggles an item, rendered inside a heading (h3 by default). Enter and Space toggle it; ArrowUp/ArrowDown/Home/End move between triggers when keyboardNavigation is on.
| Prop | Type | Default |
|---|---|---|
childrenThe trigger's visible title. Rendered in the bold display font; this is the accessible name. | ReactNode | — |
descriptionA secondary line under the title, in muted body text. Exposed as the button's accessible description. | ReactNode | — |
startIconDecorative icon before the title (hidden from assistive technology). | ReactNode | — |
badgeA slot after the title, typically a | ReactNode | — |
headingClassNameClass for the heading element that wraps the button. | string | — |
Also accepts native <button> attributes, plus className, style and ref.
Accordion.Content
The collapsible panel. Animates its height open and closed, then gets the hidden attribute so closed content is invisible to assistive technology and unfocusable. A role="region" labelled by its trigger (see regionRole).
| Prop | Type | Default |
|---|---|---|
forceMountKeep the children mounted while closed (still hidden). Overrides the accordion's | boolean | — |
hiddenUntilFoundUse | boolean | — |
bodyClassNameClass for the inner padded element that holds the children. | string | — |
childrenThe panel content. | ReactNode | — |
Also accepts native <div> attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
Accordion targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10034 passed · 1 failed · 30 not applicable · 10 to check by hand
Elements with visible text labels do not have matching accessible names.
Visible text labels that do not match the accessible name can result in a confusing experience for screen reader users. 3 elements.
div._root_aanju_11 > div._item_aanju_131 > h3._heading_aanju_251 > button#_R_kukldc_-triggerdiv._root_aanju_11 > div._item_aanju_131 > h3._heading_aanju_251 > button#_R_14ukldc_-triggerdiv._root_aanju_11 > div._item_aanju_131 > h3._heading_aanju_251 > button#_R_1kukldc_-trigger
Dark mode
Score 10034 passed · 1 failed · 30 not applicable · 10 to check by hand
Elements with visible text labels do not have matching accessible names.
Visible text labels that do not match the accessible name can result in a confusing experience for screen reader users. 3 elements.
div._root_aanju_11 > div._item_aanju_131 > h3._heading_aanju_251 > button#_R_kukldc_-triggerdiv._root_aanju_11 > div._item_aanju_131 > h3._heading_aanju_251 > button#_R_14ukldc_-triggerdiv._root_aanju_11 > div._item_aanju_131 > h3._heading_aanju_251 > button#_R_1kukldc_-trigger
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
| Key | Action |
|---|---|
| EnterSpace | Opens or closes the focused item. |
| Arrow DownArrow Up | Moves to the next or previous trigger, wrapping. Disabled items are skipped. |
| HomeEnd | Moves to the first or last trigger. |
| Tab | Moves through triggers and open panels in page order. |
Roles and states
| Element | Role | States and properties |
|---|---|---|
| Heading around each trigger | heading | Level from headingLevel |
Trigger <button> | button | aria-expanded, aria-controls → panel, aria-disabled |
| Panel | region (6 items or fewer) | aria-labelledby → trigger; hidden while closed |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |