Radio
Inherits: LayoutControl, AdaptiveControl
Properties
-
active_color(ColorValue | None) –The color used to fill this radio when it is selected.
-
autofocus(bool) –True if the control will be selected as the initial focus.
-
fill_color(ControlStateValue[ColorValue] | None) –The color that fills the radio, in all or specific
ControlStatestates. -
focus_color(ColorValue | None) –The color of this radio when it has the input focus.
-
hover_color(ColorValue | None) –The color of this radio when it is hovered.
-
label(str) –The clickable label to display on the right of a Radio.
-
label_position(LabelPosition) –Defaults to
LabelPosition.RIGHT. -
label_style(TextStyle | None) –The label's style.
-
mouse_cursor(MouseCursor | None) –The cursor for a mouse pointer entering or hovering over this control.
-
overlay_color(ControlStateValue[ColorValue] | None) –The overlay color of this radio in all or specific
ControlStatestates. -
splash_radius(Number | None) –The splash radius of the circular Material ink response.
-
toggleable(bool) –Set to
Trueif this radio button is allowed to be returned to an indeterminate -
value(str | None) –The value to set to containing
RadioGroupwhen the radio is selected. -
visual_density(VisualDensity | None) –Defines how compact the radio's layout will be.
Events
-
on_blur(ControlEventHandler[Radio] | None) –Called when the control has lost focus.
-
on_focus(ControlEventHandler[Radio] | None) –Called when the control has received focus.
Examples#
Basic Example#
import flet as ft
def main(page: ft.Page):
def handle_button_click(e: ft.Event[ft.Button]):
message.value = f"Your favorite color is: {group.value}"
page.update()
page.add(
ft.Text("Select your favorite color:"),
group := ft.RadioGroup(
content=ft.Column(
controls=[
ft.Radio(value="red", label="Red"),
ft.Radio(value="green", label="Green"),
ft.Radio(value="blue", label="Blue"),
]
)
),
ft.Button(content="Submit", on_click=handle_button_click),
message := ft.Text(),
)
ft.run(main)
Handling selection changes#
import flet as ft
def main(page: ft.Page):
def handle_selection_change(e: ft.Event[ft.RadioGroup]):
message.value = f"Your favorite color is: {e.control.value}"
page.update()
page.add(
ft.Text("Select your favorite color:"),
ft.RadioGroup(
on_change=handle_selection_change,
content=ft.Column(
controls=[
ft.Radio(value="red", label="Red"),
ft.Radio(value="green", label="Green"),
ft.Radio(value="blue", label="Blue"),
]
),
),
message := ft.Text(),
)
ft.run(main)
Styled radio buttons#
import flet as ft
def main(page: ft.Page):
page.add(
ft.RadioGroup(
ft.Column(
controls=[
ft.Radio(label="Radio with default style", value="1"),
ft.Radio(
label="Radio with constant fill color",
value="2",
fill_color=ft.Colors.RED,
),
ft.Radio(
label="Radio with dynamic fill color",
value="3",
fill_color={
ft.ControlState.HOVERED: ft.Colors.BLUE,
ft.ControlState.SELECTED: ft.Colors.GREEN,
ft.ControlState.DEFAULT: ft.Colors.RED,
},
),
]
)
)
)
ft.run(main)
Properties#
active_color
#
active_color: ColorValue | None = None
The color used to fill this radio when it is selected.
autofocus
#
autofocus: bool = False
True if the control will be selected as the initial focus.
If there is more than one control on a page with autofocus set, then the first one added to the page will get focus.
fill_color
#
fill_color: ControlStateValue[ColorValue] | None = None
The color that fills the radio, in all or specific ControlState states.
focus_color
#
focus_color: ColorValue | None = None
The color of this radio when it has the input focus.
mouse_cursor
#
mouse_cursor: MouseCursor | None = None
The cursor for a mouse pointer entering or hovering over this control.
overlay_color
#
overlay_color: ControlStateValue[ColorValue] | None = None
The overlay color of this radio in all or specific ControlState states.
splash_radius
#
splash_radius: Number | None = None
The splash radius of the circular Material ink response.
toggleable
#
toggleable: bool = False
Set to True if this radio button is allowed to be returned to an indeterminate
state by selecting it again when selected.
value
#
value: str | None = None
The value to set to containing RadioGroup when the radio is selected.
visual_density
#
visual_density: VisualDensity | None = None
Defines how compact the radio's layout will be.
Events#
on_focus
#
on_focus: ControlEventHandler[Radio] | None = None
Called when the control has received focus.

