Widgets

Slider

Slider

A material slider for selecting a value from a continuous or discrete range.

Example

slider(
  value: 40,
  min: 0,
  max: 100,
  divisions: 10,
  label: "{value}%",
  on_change: ->(event) { page.update(preview, opacity: event.control.value / 100.0) }
)

Common properties

  • value
  • min / max
  • divisions — snap to discrete steps
  • label — tooltip shown while dragging ("{value}" interpolates)
  • active_color / inactive_color
  • thumb_color
  • round — decimal places for the displayed value

Range slider

For two-handle selection, use range_slider with start_value / end_value:

range_slider(start_value: 20, end_value: 80, min: 0, max: 100, divisions: 10)

Usage

on_change fires continuously while dragging; use on_change_end to react only when the user releases.

Complete API

Helpers

  • slider(**props)

Accepted properties

  • active_color — Active color.
  • adaptive — Adapts to the platform (Material/Cupertino) when true.
  • align — Alignment of the control within its parent.
  • animate_align — Animates alignment changes.
  • animate_margin — Animates margin changes.
  • animate_offset — Animates offset changes.
  • animate_opacity — Animates opacity changes.
  • animate_position — Animates position changes.
  • animate_rotation — Animates rotation changes.
  • animate_scale — Animates scale changes.
  • animate_size — Animates size changes.
  • aspect_ratio — Width-to-height ratio to maintain.
  • autofocus — Requests focus when first shown.
  • badge — Badge drawn on the corner of the control.
  • bottom — Bottom offset when positioned inside a stack.
  • col — Responsive column span (1-12) per breakpoint.
  • data — Arbitrary value you can attach to the control and read back in handlers.
  • disabled — Disables interaction when true.
  • divisions — Number of discrete steps between min and max.
  • expand — Fills the available space along the parent's main axis when true.
  • expand_loose — Like expand, but only grows up to the child's natural size.
  • height — Fixed height in logical pixels.
  • inactive_color — Inactive color.
  • interaction — Sets the interaction property.
  • key — Stable identity used to preserve state across rebuilds.
  • label — Text label shown for the control.
  • left — Left offset when positioned inside a stack.
  • margin — Outer spacing around the control.
  • max — Maximum value.
  • min — Minimum value.
  • mouse_cursor — Cursor shown when hovering the control.
  • offset — Translation offset applied to the control.
  • opacity — Opacity from 0.0 (transparent) to 1.0 (opaque).
  • overlay_color — Overlay color.
  • padding — Inner spacing between the border and the content.
  • right — Right offset when positioned inside a stack.
  • rotate — Rotation applied to the control.
  • round — Sets the round property.
  • rtl — Renders right-to-left when true.
  • scale — Scale transform applied to the control.
  • secondary_active_color — Secondary active color.
  • secondary_track_value — Sets the secondary track value property.
  • size_change_interval — Throttle interval for on_size_change, in ms.
  • thumb_color — Thumb color.
  • tooltip — Text shown on hover/long-press.
  • top — Top offset when positioned inside a stack.
  • value — The control's current value.
  • visible — Hides the control when false.
  • width — Fixed width in logical pixels.
  • year_2023 — Sets the year 2023 property.

Events

  • on_animation_end — Fired when an animation completes.
  • on_blur — Fired when the control loses focus.
  • on_change — Fired when the value changes.
  • on_change_end — Fired when the user finishes changing the value.
  • on_change_start — Fired when the user starts changing the value.
  • on_focus — Fired when the control gains focus.
  • on_size_change — Fired when the control's size changes.

Wire reference

  • Family: materials
  • Widget type: slider