Components
Accordion
Use: Best practice English, Spanish, TagalogExamples - v1
Default
View va-accordion default in Storybook
Bordered
View va-accordion bordered in Storybook
Single Select
- Adding an
open-single
prop on theva-accordion
component will allow the user to only open one accordion at a time.
View va-accordion single select in Storybook
Subheader
View va-accordion subheader in Storybook
Internationalization
View va-accordion Internationalization in Storybook
Icon in header
View va-accordion Icon in header in Storybook
Examples - v3
View va-accordion v3 along with additional variations in Storybook
Usage
Refer to the U.S. Web Design System for usage guidance
Additional guidance for VA
Additional uses of accordions
- Organizing related sections of content to condense and chunk the content. When you need to organize related sections of content into a smaller space use accordions to condense and group the content.
- A series of content: If you have a series of content in the body of a page and outside of a form or tool. For example, if you have a series of questions as part of an FAQ section or a set of options for payment that each have additional details.
- Reveal and compare relevant information. When users need to reveal and compare relevant and related information accordions can make this easier.
Additional reasons to consider something else
- Users would benefit from seeing additional context for a discrete piece of content. Use the Additional info component instead to leverage show/hide functionality, especially in a form.
- Required content: If the majority of people need the content to accomplish the main task then it should not be hidden from view.
Behavior
- Allow users to click anywhere in the header area to expand or collapse the content; a larger target is easier to manipulate.
- Make sure interactive elements (such as links) within the collapsible region are far enough from the header that users don’t accidentally trigger a collapse. (The exact distance will depend on the device.)
Code usage
Attributes and Properties
Property | Attribute | Type | Default | Description |
---|---|---|---|---|
disableAnalytics |
disable-analytics |
boolean |
false |
If `true`, doesn't fire the CustomEvent which can be used for analytics tracking. |
openSingle |
open-single |
boolean |
false |
True if only a single item can be opened at once |
sectionHeading |
section-heading |
string |
null |
Optional accordion section heading text. Only used in analytics event. Default is null. |
uswds |
uswds |
boolean |
false |
Whether or not the component will use USWDS v3 styling. |
Events
Name | Description |
---|---|
component-library-analytics |
The event used to track usage of the component. This is emitted when an accordion item is toggled and disableAnalytics is not true. |
accordionItemToggled |
This event is fired when an accordion item is opened or closed |
Content considerations
- Keep content succinct – accordion height will fluctuate depending on the length of the content.
- If the accordion has a subheading, it should not wrap to two lines.
- In general, accordions should organize static content. Outside of the forms review page, where accordions are used to group sections of editable information, we discourage the use of form elements like radio buttons, checkboxes, and buttons within accordions. Interactive elements will not be focusable when the accordion is in a collapsed state.
Accessibility considerations
Refer to the U.S. Web Design System for accessibility guidance
Related
Component checklist
Maturity
- Guidance
- Examples, usage, code usage, content considerations, and accessibility considerations are all complete.
- Research
- VFS team conducted research on this component which is linked from this page.
- Stability
- Component has been in production for more than 3 months with no significant issues found.
- Adoption
- Multiple teams have adopted this component.
Accessibility
- Accessible use of color
- Color is not used as the only visual means of conveying information (WCAG 2.0 1.4.1).
- Accessible contrast
- Text has a contrast ratio of at least 4.5:1 for small text and at least 3:1 for large text (WCAG 2.0 1.4.3). Visual information required to identify components and states (except inactive components) has a contrast ratio of at least 3:1 (WCAG 2.1 1.4.11).
- Keyboard interactions
- Follows WCAG 2.0 standards for keyboard accessibility guidelines and includes a description of the keyboard interactions. All interactive elements can be selected and activated using the keyboard.
- Content zoom tested
- Component has been tested with the display set to 400% at 1280px viewport width to ensure that the component does not have overlapping text or elements and all interactive elements still operate.
- Tested in screen readers
- Tested with screen readers to ensure there are no issues with reading order, spelling, dynamic content, and interactive elements.
Code assets
- Variations
- Storybook includes all variations (style, size, orientation, optional iconography, selection, error state, etc.)
- Responsive
- Component depicted in all responsive breakpoints.
- Interactive states
- Includes all interactive states that are applicable (hover, active, focus, keyboard focus, disabled).
- Tokens
- All design attributes (color, typography, layout, etc.) are available as tokens.
- Internationalization
- Describes i18n attributes.
Visual assets
- Variations
- Sketch library includes all variations (style, size, orientation, optional iconography, selection, error state, etc.)
- Responsive
- Component designed to work in all responsive breakpoints.
- Interactive states
- Includes all interactive states that are applicable (hover, active, focus, keyboard focus, disabled).
- Tokens
- All design attributes (color, typography, layout, etc.) are available as tokens.
Legend:
- Complete
- Incomplete
- Not applicable