Accordion

As defined by the W3C:

An accordion is a vertically stacked set of interactive headings that each contain a title, content snippet, or thumbnail representing a section of content. The headings function as controls that enable users to reveal or hide their associated sections of content. Accordions are commonly used to reduce the need to scroll when presenting multiple sections of content on a single page.

<FluentAccordion> wraps the <fluent-accordion> element, a web component implementation of an accordion leveraging the Fluent UI design system. It uses the <FluentAccordionItem> component for defining the individual accordion items

Examples

Accordion default example

Shows simple usage of the accordion component. You can use the 'start' and 'end' slots to pre- or postfix each accordion item with an icon or text
Example
Panel one Panel one content, using the 'start' slot for extra header content (in this case an icon) Panel two
#end#
Panel two content, using the 'end' slot for extra header content
Panel three Panel three content
Panel Four
Panel four content

Last changed accordion item: item with HeaderTemplate, Expanded:

Download: 

Accordion with single expand mode

Example
Panel one Panel one content Panel two Panel two content Panel three Panel three content
Download: 

Control from code

Example
Just an item (status: closed) This accordion item can programatically be opened and closed. Use the buttons below to manipulate the state Open Close Toggle
Download: 

Documentation

FluentAccordionItem Class

Parameters

Name
Type
Default
Description
ChildContentRenderFragment?
Gets or sets the content to be rendered inside the component.
Expandedbool
False
Gets or sets a value indicating whether the item is expanded or collapsed.
Headingstring?
Gets or sets the heading of the accordion item.
Use either this or the FluentAccordionItem.HeadingTemplate parameter.'/>
If both are set, this parameter will be used.
HeadingLevelstring?
Gets or sets the level of the heading element.
Possible values: 1 | 2 | 3 | 4 | 5 | 6
HeadingTemplateRenderFragment?
Gets or sets the heading content of the accordion item.
Use either this or the FluentAccordionItem.Heading parameter.'/>
If both are set, this parameter will not be used.
OwnerFluentAccordion
Gets or sets the owning FluentTreeView.

EventCallbacks

Name
Type
Description
ExpandedChangedEventCallback<bool>
Gets or sets a callback for when the expanded state changes.

FluentAccordion Class

Parameters

Name
Type
Default
Description
ActiveIdstring?
Gets or sets the id of the active accordion item.
ChildContentRenderFragment?
Gets or sets the content to be rendered inside the component.
ExpandModeAccordionExpandMode?
Multi
Controls the expand mode of the Accordion, either allowing
single or multiple item expansion. AccordionExpandMode.

EventCallbacks

Name
Type
Description
ActiveIdChangedEventCallback<string>
Gets or sets a callback that updates the bound value.
OnAccordionItemChangeEventCallback<FluentAccordionItem>
Gets or sets a callback when a accordion item is changed.
Single
Multi
An error has occurred. This application may no longer respond until reloaded. Reload 🗙