UX4G Logo
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: Ux4gSlider for single-value selection and Ux4gRangeSlider for dual-thumb closed range selection (ClosedFloatingPointRange<Float>).
  • Tick Marks & Numerical Values: Automatic graduation ticks and value labels with showMarksAndValues = true and 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) and Medium (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
UX4G Single Slider Preview

2. Dual-Thumb Range Slider (Ux4gRangeSlider)

Dual-thumb range slider for selecting a continuous interval between minimum and maximum boundary bounds.

Ux4gRangeSliderJetpack Compose
UX4G Range Slider Preview

Kotlin Usage

1. Loan Amount Selection with Live Value Summary

LoanCalculatorSlider.kt
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)

AgeRangeFilter.kt
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

PropTypeDescriptionDefault
value *FloatCurrent slider position value.—
onValueChange *(Float) -> UnitCallback triggered when the slider value changes.—
modifierModifierCompose modifier applied to the outer layout container.Modifier
valueRangeClosedFloatingPointRange<Float>Minimum and maximum values allowed on the track.0f..100f
stepsIntNumber of discrete snap points between bounds.0
sizeUx4gSliderSizeSlider thumb and track dimensions (Small, Medium).Ux4gSliderSize.Small
enabledBooleanControls interactive touch dragging and disabled opacity.true
labelString?Title text displayed above the track.null
isRequiredBooleanDisplays a red asterisk (*) next to the label when true.false
labelIconUx4gIcon?Optional icon rendered next to the label.null
startValueTextString?Left boundary label text displayed above the track.null
endValueTextString?Right boundary label text displayed above the track.null
captionString?Descriptive helper or validation message below the track.null
captionVariantUx4gSliderCaptionVariantSeverity variant for caption text and status icons.Ux4gSliderCaptionVariant.Helper
showMarksAndValuesBooleanWhether to draw graduation tick marks and numbers below the track.false
showInputFieldsBooleanRenders editable numeric input fields for direct value entry.false
showValueLabelsBooleanDisplays formatted text value summaries above track.false
showIndicatorBooleanRenders a floating tooltip bubble above the thumb while sliding.false
valueFormatter(Float) -> StringCustom formatting function for numeric label text.{ "${it.toInt()}%" }
interactionSourceMutableInteractionSourceInteraction stream for press and drag state tracking.remember { MutableInteractionSource() }

Ux4gRangeSlider Props

PropTypeDescriptionDefault
value *ClosedFloatingPointRange<Float>Current selected start and end range interval.—
onValueChange *(ClosedFloatingPointRange<Float>) -> UnitCallback invoked when either thumb is moved.—
modifierModifierCompose modifier applied to the outer layout container.Modifier
valueRangeClosedFloatingPointRange<Float>Total permitted minimum and maximum bounds.0f..100f
stepsIntNumber of discrete snap notches between bounds.0
sizeUx4gSliderSizeThumb and track dimensions (Small, Medium).Ux4gSliderSize.Small
enabledBooleanControls interactive touch dragging and disabled opacity.true
labelString?Title text displayed above the track.null
isRequiredBooleanDisplays a red asterisk (*) next to the label when true.false
labelIconUx4gIcon?Optional icon rendered next to the label.null
startValueTextString?Left boundary label text.null
endValueTextString?Right boundary label text.null
captionString?Descriptive helper or validation message.null
captionVariantUx4gSliderCaptionVariantSeverity variant for caption text and status icons.Ux4gSliderCaptionVariant.Helper
showMarksAndValuesBooleanRenders graduation tick marks and numbers below the track.false
showInputFieldsBooleanRenders dual editable input boxes for start and end bounds.false
showValueLabelsBooleanDisplays formatted text values above the track.false
showIndicatorBooleanRenders floating tooltip bubbles above thumbs while dragging.false
valueFormatter(Float) -> StringCustom formatting function for numeric label text.{ "${it.toInt()}%" }

Ux4gSliderSize Reference

SizeThumb Diameter (Dp)Track Height (Dp)Typical Usage
Small16.dp4.dpCompact form cards, dense filter modals, and toolbars
Medium20.dp6.dpStandard mobile forms, calculators, and prominent settings

Ux4gSliderCaptionVariant Reference

VariantIconText ColorContext
HelperNoneonSurface (70% alpha)Informational instructions and step summaries
ErrorUx4gIcons.errorUx4gColors.red600Value out-of-bounds or mandatory threshold violation
WarningUx4gIcons.warningUx4gColors.secondarySoft limit threshold or conditional requirement
SuccessUx4gIcons.success_circleUx4gColors.green600Optimal value confirmation

On this page