Skip to main content

Theme

Applies a Fluent theme to its content.

All flet_fluent_ui controls inside content use this theme.

Wrapping controls in a Theme is optional: a control without a Theme ancestor uses the default blue accent color and follows the page's light or dark mode.

Example:

fluent.Theme(
accent_color=ft.Colors.PURPLE,
content=fluent.FilledButton("Themed"),
)
Theme
Theme

Inherits: LayoutControl

Properties

  • accent_color - The accent color, used for filled buttons, checked checkboxes and switches, sliders, progress indicators and focus highlights.
  • brightness - Whether to use the light or dark Fluent theme.
  • content - The control to apply the theme to.
  • font_family - The font family of the text in themed controls.

Example​

Fluent Theme​

Sourceplay_arrowTry Online
import flet_fluent_ui as fluent

import flet as ft


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

def preview(accent_color: ft.ColorValue | None):
return fluent.Theme(
accent_color=accent_color,
content=ft.Column(
tight=True,
controls=[
fluent.FilledButton("Continue"),
fluent.Checkbox(label="Checked", value=True),
fluent.ToggleSwitch(label="On", value=True),
fluent.ProgressBar(value=60, width=160),
],
),
)

page.add(
ft.SafeArea(
content=ft.Row(
spacing=32,
vertical_alignment=ft.CrossAxisAlignment.START,
controls=[
preview(None),
preview(ft.Colors.PURPLE),
preview("#107C10"),
],
)
)
)


if __name__ == "__main__":
ft.run(main)
theme
Default, purple and green accent colors

Properties​

accent_colorclass-attributeinstance-attribute​

accent_color: ColorValue | None = None

The accent color, used for filled buttons, checked checkboxes and switches, sliders, progress indicators and focus highlights.

Lighter and darker shades for hover and pressed states are derived from it.

If None, Fluent's default blue is used.

brightnessclass-attributeinstance-attribute​

brightness: Brightness | None = None

Whether to use the light or dark Fluent theme.

If None, follows the brightness of the page theme.

contentinstance-attribute​

content: Control

The control to apply the theme to.

font_familyclass-attributeinstance-attribute​

font_family: str | None = None

The font family of the text in themed controls.

If None, Fluent's default (Segoe UI Variable on Windows) is used.