Skip to main content

Checkbox

A Fluent checkbox.

Example:

fluent.Checkbox(label="Remember me", value=True)
fluent.Checkbox(label="Select all", tristate=True) # indeterminate
fluent.Checkbox(label="Disabled", disabled=True)
Checkbox
Checkbox

Inherits: LayoutControl

Properties

  • autofocus - Whether this checkbox should be focused on initial display.
  • label - The label shown next to this checkbox.
  • tristate - Whether clicking cycles through checked, indeterminate (None) and unchecked, instead of only checked and unchecked.
  • value - Whether this checkbox is checked.

Events

Example​

Fluent Checkbox​

Sourceplay_arrowTry Online
import flet_fluent_ui as fluent

import flet as ft


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

def handle_change(e: ft.Event[fluent.Checkbox]):
status.value = "Accepted" if e.control.value else "Not accepted"

status = ft.Text("Not accepted")

page.add(
ft.SafeArea(
content=ft.Column(
controls=[
fluent.Checkbox(
label="Accept terms and conditions",
on_change=handle_change,
),
fluent.Checkbox(
label="Select all (tristate)", tristate=True, value=None
),
fluent.Checkbox(label="Disabled", value=True, disabled=True),
status,
],
)
)
)


if __name__ == "__main__":
ft.run(main)
checkbox
Accepting the terms

Properties​

autofocusclass-attributeinstance-attribute​

autofocus: bool = False

Whether this checkbox should be focused on initial display.

labelclass-attributeinstance-attribute​

label: StrOrControl | None = None

The label shown next to this checkbox. Clicking it toggles the checkbox.

tristateclass-attributeinstance-attribute​

tristate: bool = False

Whether clicking cycles through checked, indeterminate (None) and unchecked, instead of only checked and unchecked.

valueclass-attributeinstance-attribute​

value: bool | None = None

Whether this checkbox is checked.

None shows the indeterminate state when tristate is True, and unchecked otherwise.

Events​

on_changeclass-attributeinstance-attribute​

on_change: ControlEventHandler[Checkbox] | None = None

Called when value changes.

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