Skip to main content

Slider

A Fluent slider, for choosing a value from a range.

Example:

fluent.Slider(value=40, on_change=lambda e: print(e.data))
Slider
Slider

Inherits: LayoutControl

Properties

  • autofocus - Whether this slider should be focused on initial display.
  • divisions - The number of discrete steps between min and max.
  • label - The text shown in a tooltip above the thumb while it is dragged.
  • max - The maximum value.
  • min - The minimum value.
  • value - The current value.
  • vertical - Whether the slider is vertical instead of horizontal.

Events

Example​

Fluent Slider​

Sourceplay_arrowTry Online
import flet_fluent_ui as fluent

import flet as ft


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

def handle_change(e: ft.Event[fluent.Slider]):
status.value = f"Volume: {round(e.control.value)}"

status = ft.Text("Volume: 40")

page.add(
ft.SafeArea(
content=ft.Column(
width=300,
controls=[
fluent.Slider(
key="volume",
value=40,
label="Volume",
on_change=handle_change,
),
fluent.Slider(value=3, max=5, divisions=5),
status,
],
)
)
)


if __name__ == "__main__":
ft.run(main)
slider
Tapping the middle of the track

Properties​

autofocusclass-attributeinstance-attribute​

autofocus: bool = False

Whether this slider should be focused on initial display.

divisionsclass-attributeinstance-attribute​

divisions: int | None = None

The number of discrete steps between min and max.

If None, the slider is continuous.

labelclass-attributeinstance-attribute​

label: str | None = None

The text shown in a tooltip above the thumb while it is dragged.

If None, no tooltip is shown.

maxclass-attributeinstance-attribute​

max: Number = 100

The maximum value.

minclass-attributeinstance-attribute​

min: Number = 0

The minimum value.

valueclass-attributeinstance-attribute​

value: Number = 0

The current value.

It must be between min and max.

verticalclass-attributeinstance-attribute​

vertical: bool = False

Whether the slider is vertical instead of horizontal.

Events​

on_changeclass-attributeinstance-attribute​

on_change: ControlEventHandler[Slider] | None = None

Called while the value changes.

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

on_change_endclass-attributeinstance-attribute​

on_change_end: ControlEventHandler[Slider] | None = None

Called when the user stops changing the value.

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

on_change_startclass-attributeinstance-attribute​

on_change_start: ControlEventHandler[Slider] | None = (
    None
)

Called when the user starts changing the value.