Slider composable with three track sizes.valueRange defines the represented range and defaults to 0f..1f.onValueChange fires continuously during a drag, and onValueChangeFinished fires once the drag or a semantic adjustment completes.startLabel, endLabel, startIcon, and endIcon sit below the ends of the track to communicate direction, such as quiet to loud.SliderDefaults, and the track and hint geometry comes from UiSetTheme.dimensions.sliders.contentDescription names the controlled value, and the interaction target stays at least 48 dp at every size, which meets the Android design requirements.SliderSize sets the track and thumb scale. The thumb stays visible and draggable at every size.SliderSize.SmallSliderSize.MediumSliderSize.LargethumbIcon.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",
)
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.onValueChangeFinished so a drag does not trigger repeated work.