fossui
Components

Slider

A horizontal slider with a draggable thumb that picks a value from a range.

A slider picks a double from a range. It is controlled: hold the value yourself, render it through value, and store the new one in onChanged. A drag or a track tap maps the pointer to a value, and arrow keys step it while Home and End jump to the ends. Colors read from the theme, so a global retheme restyles every slider at once.

import 'package:fossui/fossui.dart';

FossSlider(
  value: volume,
  semanticLabel: 'Volume',
  onChanged: (v) => setState(() => volume = v),
);

Range

min and max set the bounds, defaulting to 0 and 100. The caller holds and clamps the value.

FossSlider(
  value: temperature,
  min: 16,
  max: 30,
  semanticLabel: 'Temperature',
  onChanged: (v) => setState(() => temperature = v),
);

Divisions

The slider is continuous by default. Pass divisions to snap to that many equal steps, both under a drag and under the keyboard.

FossSlider(
  value: rating,
  max: 5,
  divisions: 5,
  semanticLabel: 'Rating',
  onChanged: (v) => setState(() => rating = v),
);

Drag callbacks

onChangeStart and onChangeEnd bracket a drag with the starting and final value, which is useful for committing a change once the gesture settles rather than on every frame.

FossSlider(
  value: seek,
  onChangeStart: (v) => pausePreview(),
  onChanged: (v) => setState(() => seek = v),
  onChangeEnd: (v) => resumeFrom(v),
);

Disabled

Pass a null onChanged, or enabled: false, to disable the control. It dims to a muted opacity and stops responding to the pointer and the keyboard.

const FossSlider(
  value: 40,
  onChanged: null,
);

One-off styling

Global retheming is the first choice, but a single slider can override the theme-resolved look with a FossSliderStyle. Every field is optional and falls back to the theme.

FossSlider(
  value: volume,
  onChanged: (v) => setState(() => volume = v),
  style: const FossSliderStyle(
    rangeColor: Color(0xFF6D28D9),
  ),
);

API

FossSlider

PropTypeDefaultDescription
valuedoublerequiredThe current value, within the range. The caller holds and clamps it.
onChangedValueChanged<double>?requiredCalled with the new value as the thumb moves. Null disables the control.
mindouble0Lower bound of the range.
maxdouble100Upper bound of the range.
divisionsint?nullNumber of equal steps to snap to. Null is continuous.
onChangeStartValueChanged<double>?nullCalled with the starting value when a drag begins.
onChangeEndValueChanged<double>?nullCalled with the final value when a drag ends.
enabledbooltrueWhether the control accepts input.
semanticLabelString?nullAccessibility name for the control.
styleFossSliderStyle?nullPer-instance overrides on the theme.

Live demo

Open the interactive gallery to try every variant, size, and state with live knobs.

On this page