A set of collapsible panels with headings.
Anatomy
Import the primitives and assemble the parts:
@using Blazix.Primitives
<AccordionRoot>
<AccordionItem>
<AccordionHeader>
<AccordionTrigger />
</AccordionHeader>
<AccordionPanel />
</AccordionItem>
</AccordionRoot>Examples
Open multiple panels
You can set up the accordion to allow multiple panels to be open at the same time using the Multiple parameter.
Hidden until found
The HiddenUntilFound parameter hides closed panels with
hidden="until-found"
so the browser can search their contents and reveal the matching panel automatically. It can be set on each
AccordionPanel, or once on AccordionRoot to apply to all panels.
To try it, press Ctrl+F (Cmd+F on macOS) and search for "restocking": the
browser opens the closed panel containing the match. When HiddenUntilFound is enabled, closed panels
always remain mounted in the DOM, which also makes their contents indexable by search engines.
Older browsers that don't support hidden="until-found" keep panels hidden until their trigger opens them,
and find-in-page skips over the contents.
API Reference
AccordionRoot
Renders a <div> element.
Other attributes are passed to the element it renders.
AccordionItem
Renders a <div> element.
Other attributes are passed to the element it renders.
AccordionHeader
Renders a <h3> element.
Other attributes are passed to the element it renders.
AccordionTrigger
Renders a <button> element.
Other attributes are passed to the element it renders.
AccordionPanel
Renders a <div> element.
Other attributes are passed to the element it renders.