Slider

Slider Widget

The Slider widget provides an intuitive way for users to select a value or range of values by dragging a handle along a track. This widget is particularly useful for adjusting numeric inputs like volume, brightness, or any other adjustable parameters that fall within a continuous or discrete range.

Key Properties and Features

  • Value Selection: Intuitive dragging interface for selecting numeric values
  • Discrete or Continuous: Option to divide the slider into discrete steps or maintain continuous sliding
  • Customizable Appearance: Extensive styling options for track, thumb, tick marks, and value indicators
  • Interactive Feedback: Visual feedback through overlays and value indicators
  • Accessibility: Support for enabled/disabled states and form validation

Base Properties

The base properties define the fundamental behavior and appearance of the slider.

PropertyTypeDescription
idstringUnique identifier for the slider
classNamestringCustom class name for styling
labelstringText label for the slider
labelHintstringAdditional hint text below the label
requiredbooleanWhether user input is required. Defaults to false
enabledbooleanWhether the slider is interactive. Defaults to true
initialValuenumberStarting value of the slider. Defaults to 0
minnumberMinimum selectable value. Defaults to 0
maxnumberMaximum selectable value. Defaults to 1
divisionsintegerNumber of discrete steps. If not set, the slider will be continuous
stylesobjectSee properties
onChangeActionAction triggered when value changes

Style Properties

The Slider widget supports extensive styling through nested style objects.

Track Style

Controls the appearance of the slider's track - the line along which the thumb moves.

PropertyTypeDescription
shapestringTrack shape ('rectangular' or 'circle'). Defaults to 'rectangular'
trackHeightnumberHeight of the track. Defaults to 2.0
borderRadiusnumberTrack's corner radius. Defaults to 0
activeColorColorColor of filled portion. Defaults to theme primary color
inactiveColorColorColor of unfilled portion. Defaults to theme inactive color
secondaryActiveColorColorSecondary active portion color. Defaults to theme secondary color
disabledActiveColorColorActive color when disabled. Defaults to grey.shade400
disabledInactiveColorColorInactive color when disabled. Defaults to grey.shade300

Thumb Style

Defines the appearance of the draggable handle.

PropertyTypeDescription
radiusnumberSize of the thumb. Defaults to 10.0
elevationnumberShadow depth when inactive. Defaults to 1.0
pressedElevationnumberShadow depth when pressed. Defaults to 2.0
thumbColorColorMain thumb color. Defaults to theme primary color
disabledThumbColorColorColor when disabled. Defaults to grey.shade400
borderWidthnumberWidth of thumb border. Defaults to 0.0
borderColorColorColor of border

Tick Mark Style

Configures the appearance of marks shown along the track when divisions are specified.

PropertyTypeDescription
shape.circle.radiusnumberSize of circular marks. Defaults to 1.0
shape.rectangular.widthnumberWidth of rectangular marks. Defaults to 2.0
shape.rectangular.heightnumberHeight of rectangular marks. Defaults to 2.0
showTicksbooleanWhether to display tick marks. Defaults to true
activeColorColorColor for active ticks. Defaults to white
inactiveColorColorColor for inactive ticks. Defaults to white with 0.5 opacity

Overlay Style

Controls the visual feedback shown during interaction.

PropertyTypeDescription
radiusnumberSize of interaction effect. Defaults to 24.0
colorColorColor of overlay. Defaults to theme primary color
opacitynumberTransparency of overlay. Defaults to 0.12

Value Indicator Style

Customizes the tooltip showing the current value.

PropertyTypeDescription
visibilitystringWhen to show indicator ('onlyForDiscrete', 'onlyForContinuous', 'always', 'never'). Defaults to 'onlyForDiscrete'
shapestringIndicator shape style ('drop', 'paddle', 'rectangular'). Defaults to 'drop'
colorColorBackground color. Defaults to theme primary color
textStyleTextStyleText appearance. Defaults to theme text style

Box Styles (Inherited)

This widget also inherits these styles:

PropertyTypeDescription
margininteger/stringMargin with CSS-style notation (1 to 4 integers) e.g. margin: 5 20 5
paddinginteger/stringPadding with CSS-style notation (1 to 4 integers) e.g. padding: 5 20 5
backgroundColorColorThe background color of this widget.
backgroundImageBackgroundImageThe background image of this widget.
backgroundGradientGradientThe background gradient of this widget.
borderBorderThe border of this widget.
shadowShadowThe shadow of this widget
clipContentbooleanSome widgets (such as Image) may bleed through the container when borderRadius is set. Use this to apply a clipping to ensure this does not happen.
widthintegerThe width of this widget.
heightintegerThe height of this widget.
borderRadiusstring or integerThe border radius of the widget. This can be specified using CSS-like notation with 1 to 4 integers. Minimum value: 0.
borderColorinteger or stringSets the border color, starting with '0xFF' for full opacity. Possible values: transparent, black, blue, white, red, grey, teal, amber, pink, purple, yellow, green, brown, cyan, indigo, lime, orange.
borderWidthintegerThickness of the border. Minimum value should be 0.
shadowColorinteger or stringSets the box shadow color starting with '0xFF' for full opacity. Possible values: transparent, black, blue, white, red, grey, teal, amber, pink, purple, yellow, green, brown, cyan, indigo, lime, orange.
shadowOffsetarrayThe values in the array define the horizontal and vertical offset of the shadow. Example: if the shadowOffset is set to [2, 4], the shadow will be offset by 2 pixels horizontally and 4 pixels vertically from its original position.
shadowRadiusstring or integerThe border radius of the widget. This can be specified using CSS-like notation with 1 to 4 integers. Minimum value: 0.
shadowStylestringThe blur style to apply on the shadow: normal, solid, outer, inner.

Base Styles (Inherited)

This widget also inherits these base styles:

PropertyTypeDescription
visiblebooleanToggle a widget visibility on/off. Note that an invisible widget will not occupy UI space, unless the visibilityTransitionDuration is specified.
visibilityTransitionDurationnumberSpecify the duration in seconds when a widget animates between visible and not visible state. Note that setting this value will cause the widget to still occupy the UI space even when it is not visible.
elevationintegerThe z-coordinate at which to place this material relative to its parent. A non-zero value will show a shadow, with its size relative to the elevation value. (Minimum: 0, Maximum: 24)
elevationShadowColorColorThe shadow color for the elevation.
elevationBorderRadiusinteger / stringIf the widget has a borderRadius, this should be changed to have the same value. Use with CSS-like notation (1 to 4 integers).
alignmentAlignmentAlign this widget relative to its parent.
stackPositionTopintegerThe distance of the child's top edge from the top of the stack. This is applicable only for Stack's children.
stackPositionBottomintegerThe distance that the child's bottom edge from the bottom of the stack. This is applicable only for Stack's children.
stackPositionLeftintegerThe distance that the child's left edge from the left of the stack. This is applicable only for Stack's children.
stackPositionRightintegerThe distance that the child's right edge from the right of the stack. This is applicable only for Stack's children.
captureWebPointerbooleanApplicable for Web only. When overlaying widgets on top of certain HTML container (e.g., Maps), the mouse click is captured by the HTML container, causing issue interacting with the widget. Use this to capture and maintain the mouse pointer on your widget.

Value Indicator Visibility Options

  • onlyForDiscrete: Shows only for sliders with divisions
  • onlyForContinuous: Shows only for continuous sliders
  • always: Always visible during interaction
  • never: Never shown

Value Indicator Shapes

  • drop: Teardrop-shaped tooltip
  • paddle: Paddle-shaped indicator
  • rectangular: Rectangular tooltip shape

By utilizing these properties and configurations, you can create highly customized slider controls that match your application's design while providing intuitive value selection for users.