Examples
Code
React
Preact/React documentation for Storybook
Style customization
The following CSS variables can be overridden to customize Accordion components:
Guidance
When to use
- Use an accordion to see an overview of multiple, related sections of content
- Use an accordion to show and hide sections as needed
When to consider alternatives
Accordions hide content from users and not everyone will notice them or understand how they work. Accordions increase cognitive load and interaction cost, as users have to make decisions about what headers to click on.
- Don't use an accordion if users need to see most or all of the information on a page.
- Don't use an accordion if there is not enough content to warrant condensing.
Usage
- Make the entire header selectable. Allow users to click anywhere in the header area to expand or collapse the content; a larger target is easier to manipulate.
- Give interactive elements enough space. Make sure interactive elements within the collapsible region are far enough from the headers that users donโt accidentally trigger a collapse.
Accessibility
Keyboard support for the Accordion header includes:
Enter
orSpacebar
- Changes the collapsed/expanded state of the associated accordion panelArrow Down
- Moves focus to the next accordion headerArrow Up
- Moves focus to the previous accordion header
Component maturity
This component meets 100% of our maturity criteria.
What does this mean?
Each component is tested against the following items to gauge the component's maturity. When using incomplete components, consider the unmet criteria as applied to your product.
For more information about how we tested and validated our work for each checklist item, read our component maturity documentation.
- Complete
Color:ย Meets AA color contrast standards for accessibility and color blindness.
- Complete
Forced Colors Mode (FCM):ย While using FCM the components text is legible and improves readability.
- Complete
WCAG 2.1 Level AA Conformance:ย All Axe checks for WCAG AA compliance have passed.
- Complete
Screen readers:ย VoiceOver, NVDA, and JAWS screen readers provide concise communication and interaction.
- Complete
Keyboard navigation:ย Component is fully navigable with a keyboard.
Accessibility
- Complete
Storybook:ย Component has stories to cover all defined props.
- Complete
Responsive:ย Component designed to work in all responsive breakpoints.
- Complete
Spanish translations:ย Includes Spanish translations for default text content.
Code
- Complete
Code:ย Tokens implemented in code.
- Complete
Design:ย Tokens implemented in the Sketch.