Accordion
Introduction
The Accordion component provides an expandable/collapsible section of content that follows the WAI-ARIA best practices. It uses native HTML <details>
and <summary>
elements for built-in accessibility and functionality.
When to use
- FAQ sections
- Content that needs to be shown/hidden
- Settings panels
- Any content that benefits from progressive disclosure
Usage
Props
Accordion component
Prop | Type | Default | Description |
---|---|---|---|
class | string | '' | Additional CSS classes to apply to the accordion wrapper |
AccordionItem component
Prop | Type | Default | Description |
---|---|---|---|
title | string | required | The header text for the accordion item |
name | string | '' | Optional group name for exclusive opening behavior |
class | string | '' | Additional CSS classes to apply to the item |
Accessibility features
- Uses native HTML
<details>
and<summary>
elements for built-in accessibility - Proper heading structure with
<h3>
elements - Keyboard navigation support:
Enter
orSpace
: Toggle accordion itemTab
: Navigate between focusable elements
- ARIA attributes automatically managed by native elements
- Respects user’s reduced-motion preferences
Styling
The Accordion component can be styled using CSS custom properties or by targeting specific classes.
Interactive example
-
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Tab to me! -
Content for second item
-
Content for third item