Accordion
A vertically stacked set of interactive headings that each reveal a section of content.
Installation
Add the Accordion component using the CLI:
Usage
The Accordion displays vertically stacked headings that reveal content when clicked. Use AccordionItem, AccordionTrigger, and AccordionContent to build each section. Each item requires a unique Value.
Examples
Multiple
Set Type="AccordionType.Multiple" to allow multiple items to be open at the same time. Each item can be toggled independently, and all items can be closed.
Collapsible
By default, clicking an open item closes it. Set Collapsible="false" to require at least one item to remain open—clicking the open item will have no effect.
Disabled
Set Disabled="true" on an AccordionItem to prevent it from being expanded or collapsed. Disabled items appear grayed out and do not respond to clicks.
With Card
The Accordion works well inside a Card for FAQ sections, settings panels, or other grouped content.
Frequently Asked Questions
API Reference
Accordion
A vertically stacked set of interactive headings that each reveal a section of content. Use with , , and .
Properties
| Name | Type | Description |
|---|---|---|
Collapsible |
bool |
When , allows the open item to be collapsed so that no item is open. Defaults to true so clicking an open item closes it. Set to false to require at least one item to remain open. |
DefaultValue |
string |
The value of the item to open by default when uncontrolled. Must match the Value of an . Used when is . |
DefaultValues |
IEnumerable<string> |
The values of items to open by default when uncontrolled. Must match the Value of components. Used when is . |
Type |
AccordionType |
Whether only one item can be open at a time () or multiple items (). |
Value |
string |
The value of the currently open item when controlled. Use with for two-way binding. Used when is . |
ValueChanged |
EventCallback<string> |
Callback fired when the open item changes. Use with for two-way binding. Used when is . |
Values |
IEnumerable<string> |
The values of the currently open items when controlled. Use with for two-way binding. Used when is . |
ValuesChanged |
EventCallback<IEnumerable<string>> |
Callback fired when the open items change. Use with for two-way binding. Used when is . |
AdditionalAttributes |
Dictionary<string, Object> |
|
Class |
string |
|
ChildContent |
RenderFragment |
The content of the accordion, typically one or more components. |
Events
| Name | Type | Description |
|---|---|---|
ValueChanged |
EventCallback<string> |
Callback fired when the open item changes. Use with for two-way binding. Used when is . |
ValuesChanged |
EventCallback<IEnumerable<string>> |
Callback fired when the open items change. Use with for two-way binding. Used when is . |
Methods
| Method | Returns | Description |
|---|---|---|
Equals |
bool |
|
GetHashCode |
int |
|
GetType |
Type |
|
SetParametersAsync |
Task |
|
ToString |
string |