Button
A Fluent button: the standard button for most actions.
See also FilledButton for the main action,
OutlinedButton,
HyperlinkButton and
IconButton.
Example:
fluent.Button("Save", on_click=lambda e: print("saved"))
fluent.Button("Save", disabled=True)

Inherits: LayoutControl
Properties
Events
on_blur- Called when this button loses focus.on_click- Called when this button is clicked.on_focus- Called when this button receives focus.on_long_press- Called when this button is long-pressed.
Methods
focus- Requests focus for this button.
Example
Fluent Button
import flet_fluent_ui as fluent
import flet as ft
def main(page: ft.Page):
page.title = "Fluent Button"
def handle_click(e: ft.Event[fluent.Button]):
status.value = "Changes discarded"
status = ft.Text("You have unsaved changes")
page.add(
ft.SafeArea(
content=ft.Column(
controls=[
ft.Row(
controls=[
fluent.Button("Discard changes", on_click=handle_click),
fluent.Button("Disabled", disabled=True),
],
),
status,
],
)
)
)
if __name__ == "__main__":
ft.run(main)

Properties
autofocusclass-attributeinstance-attribute
autofocus: bool = FalseWhether this button should be focused on initial display.
contentclass-attributeinstance-attribute
content: StrOrControl | None = NoneThe button's label.
If a string is provided, it is wrapped in a Text control.
Events
on_blurclass-attributeinstance-attribute
on_blur: ControlEventHandler[Button] | None = NoneCalled when this button loses focus.
on_clickclass-attributeinstance-attribute
on_click: ControlEventHandler[Button] | None = NoneCalled when this button is clicked.
on_focusclass-attributeinstance-attribute
on_focus: ControlEventHandler[Button] | None = NoneCalled when this button receives focus.
on_long_pressclass-attributeinstance-attribute
on_long_press: ControlEventHandler[Button] | None = NoneCalled when this button is long-pressed.