HxAccordion

Bootstrap accordion component.

Examples

Plain, No IDs

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel pharetra mi, ut ullamcorper nisl. Morbi efficitur metus eu mauris finibus suscipit ac vel nibh. Suspendisse eu ipsum orci. Donec sit amet fringilla ante, at facilisis metus. Fusce leo elit, cursus sed rutrum vel, elementum eu justo.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel pharetra mi, ut ullamcorper nisl. Morbi efficitur metus eu mauris finibus suscipit ac vel nibh. Suspendisse eu ipsum orci. Donec sit amet fringilla ante, at facilisis metus. Fusce leo elit, cursus sed rutrum vel, elementum eu justo.

Flush

Add .accordion-flush to remove the default background-color, some borders, and some rounded corners to render accordions edge-to-edge with their parent container.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel pharetra mi, ut ullamcorper nisl. Morbi efficitur metus eu mauris finibus suscipit ac vel nibh. Suspendisse eu ipsum orci. Donec sit amet fringilla ante, at facilisis metus. Fusce leo elit, cursus sed rutrum vel, elementum eu justo.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel pharetra mi, ut ullamcorper nisl. Morbi efficitur metus eu mauris finibus suscipit ac vel nibh. Suspendisse eu ipsum orci. Donec sit amet fringilla ante, at facilisis metus. Fusce leo elit, cursus sed rutrum vel, elementum eu justo.

Stay open

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel pharetra mi, ut ullamcorper nisl. Morbi efficitur metus eu mauris finibus suscipit ac vel nibh. Suspendisse eu ipsum orci. Donec sit amet fringilla ante, at facilisis metus. Fusce leo elit, cursus sed rutrum vel, elementum eu justo.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel pharetra mi, ut ullamcorper nisl. Morbi efficitur metus eu mauris finibus suscipit ac vel nibh. Suspendisse eu ipsum orci. Donec sit amet fringilla ante, at facilisis metus. Fusce leo elit, cursus sed rutrum vel, elementum eu justo.

Complex demo

Lazy loaded content...

Lorem ipsum dolor sit amet, consectetur adipiscing elit.Donec vel pharetra mi, ut ullamcorper nisl. Morbi efficitur metus eu mauris finibus suscipit ac vel nibh. Vivamus lacinia magna ut risus auctor ultrices.Aenean maximus lacus in tellus dictum posuere.Nulla facilisi. Sed vitae facilisis justo.

expandedId: 2

API

Parameters

Name Type Description
CssClass string Additional CSS classes for the accordion container.
ExpandedItemId string ID of the expanded item. Do not use constant value as it reverts the accordion to that item on every roundtrip. Use InitialExpandedItemId to set the initial state.
StayOpen bool Set to true to make accordion items stay open when another item is opened. Default is false, openning another item collapses current item.
InitialExpandedItemId string ID of the item you want to expand at the very beginning (overwrites ExpandedItemId if set).
ChildContent RenderFragment

Event Callbacks

Name Type Description
ExpandedItemIdChanged EventCallback<string>

HxAccordionItem

Single item for HxAccordion.

API

Parameters

Name Type Description
HeaderTemplate RenderFragment Clickable header (always visible).
BodyTemplate RenderFragment Body (collapsible).
Id string ID of the item (HxAccordion.ExpandedItemId). (Gets generated GUID if not set.)

Event Callbacks

Name Type Description
OnExpanded EventCallback<string> Raised after the transition to this item (the animation is finished). Is not raised for the initial rendering even if the item is not collapsed (no transition happened).
OnCollapsed EventCallback<string> Raised after the transition from this item (the animation is finished). Is not raised for the initial rendering even if the item is collapsed (no transition happened).

Methods

Method Returns Description
ExpandAsync() Task Expands the item.
CollapseAsync() Task Collapses the item.
An unhandled error has occurred. Reload 🗙