VDS

Accordion

A component with multiple configuration options for collapsing and expanding content.

Use accordions for secondary or optional information that users may want to explore. They help people quickly find relevant content without overwhelming the page.

Avoid hiding essential information or using accordions solely to reduce the amount of content visible on the page.

Focus state

Accordion triggers follow the global text-based focus state guidelines:

  • Yellow --color-yellow background
  • 3px black box-shadow at the bottom
  • Text color changes to black for contrast
  • Cursor changes to pointer on hover to indicate clickability

Focus states are triggered by keyboard navigation (Tab key) and meet WCAG 2.2 contrast requirements.

Installation

npm install @vds-testing/react @vds-testing/styles
npm install @vds-testing/elements @vds-testing/styles

See Installation for CSS setup.

Usage

React:

import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionTrigger,
} from "@vds-testing/react"
<Accordion type="single">
  <AccordionItem value="item-1">
    <AccordionTrigger>Is it accessible?</AccordionTrigger>
    <AccordionContent>
      <p className="vds-paragraph-light">Yes. It adheres to the WAI-ARIA design pattern.</p>
    </AccordionContent>
  </AccordionItem>
</Accordion>

Web Components:

<script type="module">
  import "@vds-testing/elements";
</script>
<vds-accordion type="single">
  <vds-accordion-item value="item-1">
    <vds-accordion-trigger>Is it accessible?</vds-accordion-trigger>
    <vds-accordion-content>
      <p class="vds-paragraph-light">Yes. It adheres to the WAI-ARIA design pattern.</p>
    </vds-accordion-content>
  </vds-accordion-item>
</vds-accordion>

Examples

Multiple

Multiple items can be open simultaneously. Useful when users may need to compare content across sections.