We can now use Carbon's Accordion component, which is a nicer alternative to the details tag. I switched most tags to accordions in #4628 and #4724, but there are some which will need rephrasing.
Here's the old syntax:
<details>
<summary>My *title*</summary>
Some content
</details>
And the new component:
<Accordion>
<AccordionItem title="My *title*">
Some content
</AccordionItem>
</Accordion>
(note you can place more than one AccordionItem inside an Accordion and they will collapse together in a group).
For accessibility, accordion titles should stick to the following rules:
- Only "phrasing content" is allowed. This essentially means only things which would not break onto a new line, so bold text, inline code, and inline math are fine, but blockquotes and display equations are not. Link to technical definition if that helps.
- No interactive content. Since the title is in a button, it can't contain links or other interactive content.
In addition to this, I think the title should not be too long. At the moment, if the title is long enough that it wraps, the padding goes a bit funny. While this could be considered a bug (and I'll look into it if needed), button text should really only be a few words (e.g. "Mathematical details", "Package information"), not a full sentence. If you need more information, extract that out above the accordion (e.g. a paragraph asking a question, and the accordion title says "Answer").
We can now use Carbon's
Accordioncomponent, which is a nicer alternative to thedetailstag. I switched most tags to accordions in #4628 and #4724, but there are some which will need rephrasing.Here's the old syntax:
And the new component:
(note you can place more than one
AccordionIteminside anAccordionand they will collapse together in a group).For accessibility, accordion titles should stick to the following rules:
In addition to this, I think the title should not be too long. At the moment, if the title is long enough that it wraps, the padding goes a bit funny. While this could be considered a bug (and I'll look into it if needed), button text should really only be a few words (e.g. "Mathematical details", "Package information"), not a full sentence. If you need more information, extract that out above the accordion (e.g. a paragraph asking a question, and the accordion title says "Answer").