Overview
TheAccordion component creates collapsible sections that can be expanded or collapsed by the user. It’s useful for organizing content and reducing visual clutter by hiding less frequently accessed options.
Basic usage
Parameters
str
The label of the accordion which is displayed when the accordion is collapsed.
bool
default:"False"
If True, the accordion is expanded by default. If False, it is collapsed.
bool
default:"True"
If False, accordion will be hidden.
str | None
default:"None"
An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
list[str] | str | None
default:"None"
An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
bool
default:"True"
If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
Behavior
Default state
By default, accordions are collapsed. You can change this:Examples
Organizing settings
Group related settings in collapsible sections:Help sections
Provide optional help text without cluttering the interface:Progressive disclosure
Show basic options first, hide advanced ones:Programmatically toggle accordion
Open or close accordions based on user actions:Multiple accordions
Create a FAQ-style interface:Data sections
Organize different data inputs:Methods
update
Update the accordion’s properties:Notes
Accordions are useful for progressive disclosure - showing basic options upfront while keeping advanced features accessible but hidden until needed.