Skip to main content

Expander

A Fluent expander: a header that shows or hides its content when clicked.

Example:

fluent.Expander(
header="Advanced options",
content=fluent.Checkbox(label="Enable logging"),
expanded=True,
)
Expander
Expander

Inherits: LayoutControl

Properties

Events

  • on_change - Called when the expander opens or closes.

Example​

Fluent Expander​

Sourceplay_arrowTry Online
import flet_fluent_ui as fluent

import flet as ft


def main(page: ft.Page):
page.title = "Fluent Expander"

def handle_change(e: ft.Event[fluent.Expander]):
status.value = "Expanded" if e.control.expanded else "Collapsed"

status = ft.Text("Collapsed")

page.add(
ft.SafeArea(
content=ft.Column(
width=400,
controls=[
fluent.Expander(
header="Advanced options",
leading=fluent.FluentIcons.SETTINGS,
on_change=handle_change,
content=ft.Column(
controls=[
fluent.Checkbox(label="Enable logging"),
fluent.Checkbox(label="Send diagnostics"),
],
),
),
status,
],
)
)
)


if __name__ == "__main__":
ft.run(main)
expander
Expanding the advanced options

Properties​

contentinstance-attribute​

content: Control

The control shown below (or above) header while expanded.

content_paddingclass-attributeinstance-attribute​

content_padding: PaddingValue = 16

The padding around content.

directionclass-attributeinstance-attribute​

The direction the content opens in.

expandedclass-attributeinstance-attribute​

expanded: bool = False

Whether content is shown.

headerinstance-attribute​

header: StrOrControl

The always-visible header.

leadingclass-attributeinstance-attribute​

leading: IconDataOrControl | None = None

An icon or control shown before header.

trailingclass-attributeinstance-attribute​

trailing: Control | None = None

A control shown at the end of the header, before the chevron.

Events​

on_changeclass-attributeinstance-attribute​

on_change: ControlEventHandler[Expander] | None = None

Called when the expander opens or closes.

The data property of the event handler argument contains the new expanded value.