Components
Slider
Continuous and discrete single sliders and dual-thumb range sliders with tick marks, captions, and interactive value tooltips
The UX4G Slider component enables users to select continuous or discrete values along a track. It is ideal for selecting loan amounts, subsidy tenures, citizen age criteria, income ranges, and value thresholds.
Key Capabilities
- Single & Range Sliders:
Ux4gSliderfor single-value selection andUx4gRangeSliderfor dual-thumb closed range selection (ClosedFloatingPointRange<Float>). - Tick Marks & Numerical Values: Automatic graduation ticks and value labels with
showMarksAndValues = trueand configurable step intervals (steps). - Interactive Tooltip Indicator: Floating tooltip bubble (
showIndicator = true) displaying live values directly above the sliding thumb. - Labels & Validation Captions: Form field labels with required asterisk (
*), info icons (labelIcon), start/end labels, and status captions (Helper,Error,Warning,Success). - Size Options:
Small(16dp thumb, 4dp track) andMedium(20dp thumb, 6dp track).
Import from com.ux4g.designsystemv1.components.slider.*.
Interactive Previews
1. Continuous Slider (Ux4gSlider)
Single-thumb slider with graduation tick marks, numeric scale labels, and continuous position tracking.
Ux4gSliderJetpack Compose

2. Dual-Thumb Range Slider (Ux4gRangeSlider)
Dual-thumb range slider for selecting a continuous interval between minimum and maximum boundary bounds.
Ux4gRangeSliderJetpack Compose

Kotlin Usage
1. Loan Amount Selection with Live Value Summary
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.ux4g.designsystemv1.components.slider.*
import com.ux4g.designsystemv1.foundation.Ux4gIcons
@Composable
fun LoanAmountCalculator() {
var amount by remember { mutableFloatStateOf(50000f) }
Column(
modifier = Modifier.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
Ux4gSlider(
value = amount,
onValueChange = { amount = it },
valueRange = 10000f..500000f,
steps = 48,
size = Ux4gSliderSize.Medium,
label = "Sanctioned Loan Amount",
isRequired = true,
labelIcon = Ux4gIcons.info_circle,
startValueText = "₹ 10,000",
endValueText = "₹ 5,00,000",
showIndicator = true,
showMarksAndValues = false,
caption = "Repayment tenure: 12 to 60 Months",
captionVariant = Ux4gSliderCaptionVariant.Helper
)
}
}2. Dual-Thumb Range Slider (Eligibility Age Criteria)
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.ux4g.designsystemv1.components.slider.*
@Composable
fun AgeEligibilityRangeFilter() {
var ageRange by remember { mutableStateOf(21f..60f) }
Ux4gRangeSlider(
value = ageRange,
onValueChange = { ageRange = it },
valueRange = 18f..80f,
steps = 30,
size = Ux4gSliderSize.Medium,
label = "Applicant Age Range",
startValueText = "Min: 18 yrs",
endValueText = "Max: 80 yrs",
showIndicator = true,
showMarksAndValues = true,
caption = "Eligible age bracket for state pension scheme",
captionVariant = Ux4gSliderCaptionVariant.Success
)
}Parameters
Ux4gSlider Props
| Prop | Type | Description | Default |
|---|---|---|---|
value * | Float | Current slider position value. | — |
onValueChange * | (Float) -> Unit | Callback triggered when the slider value changes. | — |
modifier | Modifier | Compose modifier applied to the outer layout container. | Modifier |
valueRange | ClosedFloatingPointRange<Float> | Minimum and maximum values allowed on the track. | 0f..100f |
steps | Int | Number of discrete snap points between bounds. | 0 |
size | Ux4gSliderSize | Slider thumb and track dimensions (Small, Medium). | Ux4gSliderSize.Small |
enabled | Boolean | Controls interactive touch dragging and disabled opacity. | true |
label | String? | Title text displayed above the track. | null |
isRequired | Boolean | Displays a red asterisk (*) next to the label when true. | false |
labelIcon | Ux4gIcon? | Optional icon rendered next to the label. | null |
startValueText | String? | Left boundary label text displayed above the track. | null |
endValueText | String? | Right boundary label text displayed above the track. | null |
caption | String? | Descriptive helper or validation message below the track. | null |
captionVariant | Ux4gSliderCaptionVariant | Severity variant for caption text and status icons. | Ux4gSliderCaptionVariant.Helper |
showMarksAndValues | Boolean | Whether to draw graduation tick marks and numbers below the track. | false |
showInputFields | Boolean | Renders editable numeric input fields for direct value entry. | false |
showValueLabels | Boolean | Displays formatted text value summaries above track. | false |
showIndicator | Boolean | Renders a floating tooltip bubble above the thumb while sliding. | false |
valueFormatter | (Float) -> String | Custom formatting function for numeric label text. | { "${it.toInt()}%" } |
interactionSource | MutableInteractionSource | Interaction stream for press and drag state tracking. | remember { MutableInteractionSource() } |
Ux4gRangeSlider Props
| Prop | Type | Description | Default |
|---|---|---|---|
value * | ClosedFloatingPointRange<Float> | Current selected start and end range interval. | — |
onValueChange * | (ClosedFloatingPointRange<Float>) -> Unit | Callback invoked when either thumb is moved. | — |
modifier | Modifier | Compose modifier applied to the outer layout container. | Modifier |
valueRange | ClosedFloatingPointRange<Float> | Total permitted minimum and maximum bounds. | 0f..100f |
steps | Int | Number of discrete snap notches between bounds. | 0 |
size | Ux4gSliderSize | Thumb and track dimensions (Small, Medium). | Ux4gSliderSize.Small |
enabled | Boolean | Controls interactive touch dragging and disabled opacity. | true |
label | String? | Title text displayed above the track. | null |
isRequired | Boolean | Displays a red asterisk (*) next to the label when true. | false |
labelIcon | Ux4gIcon? | Optional icon rendered next to the label. | null |
startValueText | String? | Left boundary label text. | null |
endValueText | String? | Right boundary label text. | null |
caption | String? | Descriptive helper or validation message. | null |
captionVariant | Ux4gSliderCaptionVariant | Severity variant for caption text and status icons. | Ux4gSliderCaptionVariant.Helper |
showMarksAndValues | Boolean | Renders graduation tick marks and numbers below the track. | false |
showInputFields | Boolean | Renders dual editable input boxes for start and end bounds. | false |
showValueLabels | Boolean | Displays formatted text values above the track. | false |
showIndicator | Boolean | Renders floating tooltip bubbles above thumbs while dragging. | false |
valueFormatter | (Float) -> String | Custom formatting function for numeric label text. | { "${it.toInt()}%" } |
Ux4gSliderSize Reference
| Size | Thumb Diameter (Dp) | Track Height (Dp) | Typical Usage |
|---|---|---|---|
Small | 16.dp | 4.dp | Compact form cards, dense filter modals, and toolbars |
Medium | 20.dp | 6.dp | Standard mobile forms, calculators, and prominent settings |
Ux4gSliderCaptionVariant Reference
| Variant | Icon | Text Color | Context |
|---|---|---|---|
Helper | None | onSurface (70% alpha) | Informational instructions and step summaries |
Error | Ux4gIcons.error | Ux4gColors.red600 | Value out-of-bounds or mandatory threshold violation |
Warning | Ux4gIcons.warning | Ux4gColors.secondary | Soft limit threshold or conditional requirement |
Success | Ux4gIcons.success_circle | Ux4gColors.green600 | Optimal value confirmation |