A detail contains answers to questions I have about confusing text.
The Details component contains helpful context for users but may not be necessary to display by default. It always follows complex text or lengthy descriptions.
The visual appearance is modified using design tokens from the Honeycrisp Reveal molecule. Further customization is applied using the CSS modifier(s).cfa-details 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
Placement. The component always follows complex text or lengthy descriptions. This is because the content in the component should answer potential questions related to it’s preceding content.
Collapsed by default. There is a risk of users skipping content in the component. Therefore, it should never contain critical information if it is always closed by default.
Open by default, collapsed when revisiting. Ideally, the component is open by default. If the user leaves the screen containing the component and returns, then the component can be closed.
When to use something else.
Stacking collapsable sections of text. Accordions are used to consolidate long pages of text containing multiple headings. The Details component uses code that can’t be applied to this use case in a reliable way for screen reader users.
Long text blocks such as legal information. Text wells are used to contain extremely lengthy blocks of text. The Details component should contain shorter blocks of supplementary content.
JavaScript enables the expansion and collapse of the details region. It also toggles the ARIA expanded attribute on the summary button and the tabindex attribute on potentially focusable children inside the details region. The module can be found at ./cfa-details.js. 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.