Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Data display

Accordion

Free4.2 KB gzipped

A 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

tsx
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.

tsx
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.

tsx
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.

tsx
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 ימים.

tsx
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

Accordion props
PropTypeDefault
type

single allows one open item at a time; multiple allows any number.

"single""multiple""single"
collapsible

In single mode, whether the open item can be closed so none is open.

boolean | nevertrue
value

Controlled open item value (null for none).

string | null | string[]—
defaultValue

Initially open item value when uncontrolled.

string | null | string[]null
onValueChange

Called with the open item value (or null) when it changes.

(value: string | null) => void | (value: string[]) => void—
variant

Visual style.

"separated""contained""flush""separated"
size

Trigger padding and type size.

"sm""md""lg""md"
headingLevel

Heading level wrapping each trigger. Choose it by the page outline; override per item.

1234563
icon

Expand indicator: "chevron", "plus-minus", "none", a custom element, or a render function.

AccordionIcon"chevron"
iconPosition

Side of the trigger the indicator sits on.

"start""end""end"
keyboardNavigation

WAI-ARIA APG arrow-key navigation between triggers (ArrowUp/ArrowDown wrap, Home, End). Tab always works.

booleantrue
regionRole

Panel landmark behavior. "auto" uses role="region" only when there are 6 items or fewer.

falsetrue"auto""auto"
forceMount

Keep every panel's children mounted while closed (still hidden from view and assistive technology).

booleanfalse
hiddenUntilFound

Hide closed panels with hidden="until-found" so the browser's find-in-page can search them; a match opens the item (via the beforematch event). Implies forceMount. Falls back to plain hidden in browsers without support (feature-detected with "onbeforematch" in document.body).

booleanfalse
disabled

Disable every item.

booleanfalse
children

Accordion.Item elements.

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.

Accordion.Item props
PropTypeDefault
valueRequired

Unique value identifying this item in the accordion's value.

string—
disabled

Prevent opening or closing this item. Its trigger is a disabled button and is skipped by arrow keys.

booleanfalse
headingLevel

Heading level for this item's trigger, overriding the accordion's headingLevel.

123456—
children

One Accordion.Trigger followed by one Accordion.Content.

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.

Accordion.Trigger props
PropTypeDefault
children

The trigger's visible title. Rendered in the bold display font; this is the accessible name.

ReactNode—
description

A secondary line under the title, in muted body text. Exposed as the button's accessible description.

ReactNode—
startIcon

Decorative icon before the title (hidden from assistive technology).

ReactNode—
badge

A slot after the title, typically a Badge. Its text is included in the accessible name.

ReactNode—
headingClassName

Class 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).

Accordion.Content props
PropTypeDefault
forceMount

Keep the children mounted while closed (still hidden). Overrides the accordion's forceMount.

boolean—
hiddenUntilFound

Use hidden="until-found" so find-in-page can reveal this panel. Overrides the accordion's hiddenUntilFound.

boolean—
bodyClassName

Class for the inner padded element that holds the children.

string—
children

The 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)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

34 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 100

34 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

Keyboard
KeyAction
EnterSpaceOpens or closes the focused item.
Arrow DownArrow UpMoves to the next or previous trigger, wrapping. Disabled items are skipped.
HomeEndMoves to the first or last trigger.
TabMoves through triggers and open panels in page order.

Roles and states

Roles and states
ElementRoleStates and properties
Heading around each triggerheadingLevel from headingLevel
Trigger <button>buttonaria-expanded, aria-controls → panel, aria-disabled
Panelregion (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.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery 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)
FocusFocus 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 readersNames, 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)
ColorMeaning 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 reflowAt 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 targetsClick 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)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)