KSlider - farimarwat/KrossUi GitHub Wiki
KSlider
Component Documentation
🎚️ A multiplatform (Android + iOS) customizable slider component for value selection within a defined range.
🔹 Overview
Element | Type | Description |
---|---|---|
KSlider |
Composable | A horizontal slider to select a float value. |
KSlider
🧩 Definition:
A composable horizontal slider component that allows users to select a floating-point value between a minimum and maximum. It supports customization of colors and a callback for value changes.
Parameters
Parameter | Type | Default | Description |
---|---|---|---|
modifier |
Modifier |
Modifier |
Modifier for layout and styling. |
value |
Float |
0f |
Current slider value. |
minValue |
Float |
0f |
Minimum allowed value. |
maxValue |
Float |
1f |
Maximum allowed value. |
colors |
KSliderColors |
KSliderDefaults.colors() |
Colors for active/inactive tracks and thumb. |
onValueChanged |
(Float) -> Unit |
{} |
Callback triggered when the slider value changes. |
KSliderColors
🎨 Defines the color configuration for the slider component.
Property | Type | Description |
---|---|---|
activeTrackColor |
Color |
Color of the filled (active) part of the slider track. |
inactiveTrackColor |
Color |
Color of the unfilled (inactive) part of the track. |
thumbColor |
Color |
Color of the slider thumb. |
disabledActiveTrackColor |
Color |
Color when active track is disabled. |
disabledInactiveTrackColor |
Color |
Color when inactive track is disabled. |
disabledThumbColor |
Color |
Color of the thumb when disabled. |
KSliderDefaults
⚙️ Provides default values and configuration for KSlider
.
colors(...)
Parameter | Type | Default Value | Description |
---|---|---|---|
activeTrackColor |
Color |
PlatformColors.systemBlue |
Color of the filled part of the track. |
inactiveTrackColor |
Color |
PlatformColors.systemGray |
Color of the empty part of the track. |
thumbColor |
Color |
Color.White |
Color of the draggable thumb. |
disabledActiveTrackColor |
Color |
activeTrackColor.copy(...) |
Dimmed color for disabled active track. |
disabledInactiveTrackColor |
Color |
inactiveTrackColor.copy(...) |
Dimmed color for disabled inactive track. |
disabledThumbColor |
Color |
thumbColor.copy(...) |
Dimmed color for the thumb when disabled. |
Returns a KSliderColors
instance with the specified or default values.
✅ Usage Example
var sliderValue by remember { mutableStateOf(0.5f) }
KSlider(
modifier = Modifier.fillMaxWidth(),
value = sliderValue,
onValueChanged = {
sliderValue = it
println("Slider Value: $it")
}
)
🔹 Note:
value
must be aFloat
between0f
and1f
.onValueChanged
provides live updates when the user slides.- Looks and behaves natively on both Android and iOS.