Develop

Slider

Updated: Aug 29, 2026

Overview

Sliders allow users to select a value from a continuous range by dragging a thumb along a track. They suit settings such as volume, brightness, and playback position. The Meta VR UI Set SDK provides one Slider composable with three track sizes.

Common features

  • Range: valueRange defines the represented range and defaults to 0f..1f.
  • Callbacks: onValueChange fires continuously during a drag, and onValueChangeFinished fires once the drag or a semantic adjustment completes.
  • Hints: startLabel, endLabel, startIcon, and endIcon sit below the ends of the track to communicate direction, such as quiet to loud.
  • Theming: Active, inactive, icon, and disabled colors come from SliderDefaults, and the track and hint geometry comes from UiSetTheme.dimensions.sliders.
  • Accessibility: contentDescription names the controlled value, and the interaction target stays at least 48 dp at every size, which meets the Android design requirements.

Slider sizes

SliderSize sets the track and thumb scale. The thumb stays visible and draggable at every size.

Small

  • Value: SliderSize.Small
  • Appearance: An 8 dp track with a small thumb.
  • Usage: Dense layouts and fine adjustments.

Medium

  • Value: SliderSize.Medium
  • Appearance: A 28 dp track. This is the default.
  • Usage: General settings.

Large

  • Value: SliderSize.Large
  • Appearance: A 40 dp track that gives the thumb the most emphasis. This is the only size that renders thumbIcon.
  • Usage: Prominent controls, such as a master volume.

Usage example

import metavrx.uiset.compose.Icon
import metavrx.uiset.compose.slider.Slider
import metavrx.uiset.compose.slider.SliderSize
import metavrx.uiset.compose.theme.icons.Icons

var volume by remember { mutableFloatStateOf(0.7f) }
var brightness by remember { mutableFloatStateOf(0.3f) }

Slider(
    value = volume,
    onValueChange = { volume = it },
    onValueChangeFinished = { saveVolume(volume) },
    contentDescription = "Volume",
    size = SliderSize.Large,
    thumbIcon = { Icon(Icons.Regular.VolumeOn, contentDescription = null) },
    startIcon = { Icon(Icons.Regular.VolumeLow, contentDescription = null) },
    endIcon = { Icon(Icons.Regular.VolumeOn, contentDescription = null) },
)

Slider(
    value = brightness,
    onValueChange = { brightness = it },
    contentDescription = "Brightness",
    startLabel = "Dim",
    endLabel = "Bright",
)

Common parameters

  • value: Float: The current value, within valueRange.
  • onValueChange: (Float) -> Unit: Receives values while the reader drags. Update your state here.
  • onValueChangeFinished: (() -> Unit)? = null: Runs after the interaction completes. Save the setting here rather than on every frame of the drag.
  • size: SliderSize = SliderSize.Medium: Track and thumb scale.
  • thumbIcon: (@Composable () -> Unit)? = null: Icon inside the thumb. Rendered only at SliderSize.Large.
  • startLabel, endLabel, startIcon, and endIcon: Hints below the ends of the track.
  • valueRange: ClosedFloatingPointRange<Float> = 0f..1f: The range the track represents.
  • enabled: Boolean = true: Controls interactivity.
  • colors: SliderColors and dimensions: SliderDimensions: Colors and geometry.
  • modifier: Modifier = Modifier: Applied to the slider and its hints.
Match the size to the prominence of the control and the space available, and write the final value in onValueChangeFinished so a drag does not trigger repeated work.