Accordion
An accordion helps me scan long pages by letting me show or hide sections of text.
The Accordion component allows users to find information on a page by clicking headings to expand or hide content beneath. They are always used to collapse multiple heading groups and are most useful for fitting long-form content into a limited space.
Details
- Extends: USWDS Accordion component
- Honeycrisp: Accordion molecule
- Customization: Design tokens and Styles
- Modifier:
.cfa-accordion .usa-accordion--bordered
The Accordion extends the USWDS Accordion component. The visual appearance is modified using design tokens applied to the USWDS Accordion component settings from the Honeycrisp Accordion molecule. Further customization is applied using the CSS modifier(s) .cfa-accordion .usa-accordion--bordered
to add styles defined in a custom stylesheet.
Design tokens. Tokens define the name of basic system elements such as color, typography, or spacing. The values of tokens are relative to how the system defines them. This enables teams to alter the visual appearance of components yet remain within the system boundaries. Learn more about tokens on the Bixal's Design Tokens Guide.
Modifier. A modifier is a class name that applies a variant, type, or extended style customization to modify the component's visual appearance.
Examples
Guidance
Heading order. It is a best practice to ensure the accordion heading level does not skip and is in order with other page headings. However, this does not contribute to accessible success criteria.
Refer to additional guidance on the USWDS documentation site.
USWDS documentation siteAdditional references
Accessibility
Refer to additional accessibility guidance on the USWDS documentation site.
Checklist Key
Design library component
Source and usage
- Sass stylesheet:
./_cfa-accordion.scss
- Thymeleaf template fragment:
./cfa-accordion.th.html
- Embedded Ruby (ERB) partial template:
./_cfa-accordion.html.erb
- JavaScript
enables the expanding and collapsing of accordion sections as well as toggles ARIA attributes on the button and target region.
Guidance on individual module loading will added. Currently, there is one script that imports all modules. The source is located at
@codeforamerica/js/index.js
. This entrypoint is compiled using Rollup.js and distributed to@codeforamerica/dist/js/default.js
.