[Question] How to change selected color of a SegmentedButton? #5812
Answered
by
ndonkoHenri
Corneille-B
asked this question in
Q&A
-
QuestionHi, Code samplemyTheme.py
from ressources import colors
[...]
def createTheme():
return ft.Theme(
color_scheme=ft.ColorScheme(
primary=colors.ORANGE,
secondary=colors.BLUE,
background="#2F20AF",
surface=colors.BLACK5,
error=colors.RED,
),
[...]
example.py
[...]
ft.SegmentedButton(
width=250,
selected={"Opt1"},
segments=[
ft.Segment(
value="Opt1",
label=ft.Text("Opt1"),
),
ft.Segment(
value="Opt2",
label=ft.Text("Opt2"),
),
]
)
[...]Error messageNo response ------------------------------------------------------
|
Beta Was this translation helpful? Give feedback.
Answered by
ndonkoHenri
Nov 22, 2025
Replies: 1 comment
-
|
You can set it through the import flet as ft
def main(page: ft.Page):
page.theme_mode = ft.ThemeMode.LIGHT
# page.theme = page.dark_theme = ft.Theme(
# segmented_button_theme=ft.SegmentedButtonTheme(
# style=ft.ButtonStyle(...),
# )
# )
page.add(
ft.SegmentedButton(
selected_icon=ft.Icon(ft.Icons.CHECK_SHARP),
selected=["2"],
allow_multiple_selection=False,
segments=[
ft.Segment(
value="1",
label=ft.Text("Item One"),
icon=ft.Icon(ft.Icons.LOOKS_ONE),
),
ft.Segment(
value="2",
label=ft.Text("Item Two"),
icon=ft.Icon(ft.Icons.LOOKS_TWO),
),
],
style=ft.ButtonStyle(
color={
ft.ControlState.DEFAULT: ft.Colors.ERROR,
ft.ControlState.HOVERED: ft.Colors.BLUE,
ft.ControlState.SELECTED: ft.Colors.GREEN,
},
),
)
)
ft.run(main)
I am running this example with the latest pre-release. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Corneille-B
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

You can set it through the
SegmentedButton.styleor theTheme.segmented_button_themeprops: