FontWeight
Inherits: Enum
Properties
-
BOLD–A commonly used font weight that is heavier than normal, equal to
w700. -
NORMAL–The default font weight, equal to
w400. -
W_100–Thin, the least thick.
-
W_200–Extra-light.
-
W_300–Light.
-
W_400–Normal / regular / plain.
-
W_500–Medium.
-
W_600–Semi-bold.
-
W_700–Bold.
-
W_800–Extra-bold.
-
W_900–Black, the most thick.
Examples#
Showcase#
import flet as ft
SAMPLE_TEXT = "Sphinx of black quartz"
def showcase_card(weight: ft.FontWeight) -> ft.Container:
return ft.Container(
width=300,
padding=12,
border=ft.Border.all(1, ft.Colors.RED),
border_radius=10,
bgcolor=ft.Colors.SURFACE_CONTAINER_LOW,
content=ft.Column(
spacing=8,
controls=[
ft.Text(weight.name, size=12, color=ft.Colors.ON_SURFACE_VARIANT),
ft.Text(SAMPLE_TEXT, weight=weight, size=24),
],
),
)
def main(page: ft.Page):
page.theme_mode = ft.ThemeMode.DARK
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
page.appbar = ft.AppBar(title="FontWeight Showcase")
page.add(
ft.Text("Compare text thickness across all FontWeight values."),
ft.Row(
wrap=True,
spacing=12,
expand=True,
scroll=ft.ScrollMode.AUTO,
alignment=ft.MainAxisAlignment.CENTER,
controls=[showcase_card(weight) for weight in ft.FontWeight],
),
)
ft.run(main)
Properties#
BOLD = 'bold'
class-attribute
instance-attribute
#
A commonly used font weight that is heavier than normal, equal to w700.
NORMAL = 'normal'
class-attribute
instance-attribute
#
The default font weight, equal to w400.
W_100 = 'w100'
class-attribute
instance-attribute
#
Thin, the least thick.
W_200 = 'w200'
class-attribute
instance-attribute
#
Extra-light.
W_300 = 'w300'
class-attribute
instance-attribute
#
Light.
W_400 = 'w400'
class-attribute
instance-attribute
#
Normal / regular / plain.
W_500 = 'w500'
class-attribute
instance-attribute
#
Medium.
W_600 = 'w600'
class-attribute
instance-attribute
#
Semi-bold.
W_700 = 'w700'
class-attribute
instance-attribute
#
Bold.
W_800 = 'w800'
class-attribute
instance-attribute
#
Extra-bold.
W_900 = 'w900'
class-attribute
instance-attribute
#
Black, the most thick.