Accordion
A Shadcn accordion: a vertical list of sections that expand to show their content.
Example:
shad.Accordion(
items=[
shad.AccordionItem(
value="a11y",
title="Is it accessible?",
content=ft.Text("Yes. It adheres to the WAI-ARIA design pattern."),
),
]
)

Inherits: LayoutControl
Example
Shadcn Accordion
play_arrowTry Online
import flet_shadcn_ui as shad
import flet as ft
FAQ = [
("a11y", "Is it accessible?", "Yes. It adheres to the WAI-ARIA design pattern."),
(
"styled",
"Is it styled?",
"Yes. It comes with default styles that match the other components.",
),
(
"animated",
"Is it animated?",
"Yes. It's animated by default, but you can disable it if you prefer.",
),
]
def main(page: ft.Page):
page.title = "Shadcn Accordion"
def handle_change(e: ft.Event[shad.Accordion]):
status.value = f"Expanded: {', '.join(e.control.value) or 'none'}"
status = ft.Text("Expanded: none")
page.add(
ft.SafeArea(
content=ft.Column(
width=420,
controls=[
shad.Accordion(
on_change=handle_change,
items=[
shad.AccordionItem(
value=value, title=title, content=ft.Text(answer)
)
for value, title, answer in FAQ
],
),
status,
],
)
)
)
if __name__ == "__main__":
ft.run(main)

Properties
itemsclass-attributeinstance-attribute
items: list[AccordionItem] = field(default_factory=list)The sections of this accordion.
multipleclass-attributeinstance-attribute
multiple: bool = FalseWhether several items can be expanded at the same time.
Events
on_changeclass-attributeinstance-attribute
on_change: ControlEventHandler[Accordion] | None = NoneCalled when the user expands or collapses an item.
The data property of the event handler argument
contains the new value.