KmpSlider

fun KmpSlider(value: Float, range: ClosedRange<Float>, step: Float = 1.0f, isEnabled: Boolean = true, ticks: List<KmpSliderTick> = emptyList(), units: String? = null, label: String? = null, valueFormatter: (value: Float) -> String = remember { { it.roundToInt().toString() } }, modifier: Modifier = Modifier, direction: KmpSliderDirection = KmpSliderDirection.Horizontal, logarithmic: Boolean = false, styles: KmpSliderStyle = remember { KmpSliderStyle() }, layoutSlot: @Composable KmpSliderScope.() -> Unit = { DefaultLayout() }, labelSlot: @Composable KmpSliderScope.() -> Unit = { Label() }, valueLabelSlot: @Composable KmpSliderScope.() -> Unit? = { ValueLabel() }, thumbSlot: @Composable KmpSliderScope.(key: String) -> Unit = { Thumb(it) }, trackDecoratorSlot: @Composable KmpSliderTrackScope.(trackFill: @Composable KmpSliderTrackScope.() -> Unit) -> Unit = { TrackDecoration { it() } }, manualEntryState: MutableState<Boolean>? = remember { mutableStateOf(false) }, manualEntrySlot: KmpSliderManualEntrySlot = { isVisible, valueString, onTextChange, onCancel, onCommit -> ManualEntryModal( isVisible = isVisible, valueString = valueString, onTextChange = onTextChange, onCancel = onCancel, onCommit = onCommit, ) }, onDragStart: (Float) -> Unit = { }, onDragDone: (Float) -> Unit = { }, onChange: (Float) -> Unit)

A flexible and customizable Slider

Parameters

value

The current value of the slider

range

The allowable range of the current value

step

The increment between selectable values

isEnabled

If interaction with the slider is enabled or not

ticks

The list of ticks to mark on the slider

units

The units the slider value represents (i.e., millimeters, Hz, dB, .etc.)

label

The label for the slider. Setting to null will not render any label.

valueFormatter

Formats the float value into a string for display in the value label and manual entry modal

direction

The direction the slider is displayed; horizontal (default) or vertical

logarithmic

Sets the scale interpretation to be logarithmic rather than linear

styles

Styles to customize the look and feel of default elements

layoutSlot

An optional composable to control the layout of the Slider

labelSlot

An optional composable to control the look and layout of the label

valueLabelSlot

An optional composable to control the look and layout of the value label. Setting to null will not render a value label.

thumbSlot

An optional composable to control the look and layout of the Thumb

trackDecoratorSlot

An optional composable to control the look and layout of the track

manualEntryState

Mutable state to control if the manual entry is open or not

manualEntrySlot

An optional composable to control the look and layout of manual entry

onDragStart

The callback for when the user begins interacting with a thumb

onDragDone

The callback for when the user stops interacting with a thumb

onChange

The callback for when the value changes


fun KmpSlider(values: Map<String, Float>, range: ClosedRange<Float>, step: Float = 1.0f, isEnabled: Boolean = true, ticks: List<KmpSliderTick> = emptyList(), units: String? = null, label: String? = null, valueFormatter: (value: Float) -> String = remember { { it.roundToInt().toString() } }, modifier: Modifier = Modifier, direction: KmpSliderDirection = KmpSliderDirection.Horizontal, multiThumbMode: MultiThumbMode = MultiThumbMode.Range, deadband: Float? = null, logarithmic: Boolean = false, styles: KmpSliderStyle = remember { KmpSliderStyle() }, layoutSlot: @Composable KmpSliderScope.() -> Unit = { DefaultLayout() }, labelSlot: @Composable KmpSliderScope.() -> Unit = { Label() }, valueLabelSlot: @Composable KmpSliderScope.() -> Unit? = { ValueLabel() }, thumbSlot: @Composable KmpSliderScope.(key: String) -> Unit = { Thumb(it) }, trackDecoratorSlot: @Composable KmpSliderTrackScope.(trackFill: @Composable KmpSliderTrackScope.() -> Unit) -> Unit = { TrackDecoration { it() } }, manualEntryState: MutableState<Boolean>? = remember { mutableStateOf(false) }, manualEntrySlot: KmpSliderManualEntrySlot = { isVisible, valueString, onTextChange, onCancel, onCommit -> ManualEntryModal( isVisible = isVisible, valueString = valueString, onTextChange = onTextChange, onCancel = onCancel, onCommit = onCommit, ) }, onDragStart: (Map<String, Float>) -> Unit = { }, onDragDone: (Map<String, Float>) -> Unit = { }, onChange: (Map<String, Float>) -> Unit)

A flexible and customizable Slider

Parameters

value

The current value of the slider

range

The allowable range of the current value

step

The increment between selectable values

isEnabled

If interaction with the slider is enabled or not

ticks

The list of ticks to mark on the slider

units

The units the slider value represents (i.e., millimeters, Hz, dB, .etc.)

label

The label for the slider. Setting to null will not render a label.

valueFormatter

Formats the float value into a string for display in the value label and manual entry modal

direction

The direction the slider is displayed; horizontal (default) or vertical

multiThumbMode

Sets the mode multiple thumbs should work.

  • Range: show all thumbs and allow them to be interacted with individually

  • Group: Show one thumb for all values. The thumb will grow on the main axis to show the full size of the values. Moving the thumb will adjust all values by the same distance.

deadband

The minimum allowed distance between two thumbs. This is only used when multiThumbMode is Range.

logarithmic

Sets the scale interpretation to be logarithmic rather than linear

styles

Styles to customize the look and feel of default elements

layoutSlot

An optional composable to control the layout of the Slider

labelSlot

An optional composable to control the look and layout of the label

valueLabelSlot

An optional composable to control the look and layout of the value label. Setting to null will not render a value label.

thumbSlot

An optional composable to control the look and layout of the Thumb

trackDecoratorSlot

An optional composable to control the look and layout of the track

manualEntryState

Mutable state to control if the manual entry is open or not

manualEntrySlot

An optional composable to control the look and layout of manual entry

onDragStart

The callback for when the user begins interacting with a thumb

onDragDone

The callback for when the user stops interacting with a thumb

onChange

The callback for when the value changes. Only changed thumb values will be passed.