Skip to content

Stepper

A stepper lets the user adjust an integer value in fixed increments using a minus and a plus button, mirroring ColorOS's COUIStepperView (32dp circular buttons with the OPLUS step haptic).

Import

kotlin
import io.github.suqi8.coui.kmp.basic.Stepper
import io.github.suqi8.coui.kmp.basic.StepperDefaults

Basic Usage

kotlin
var value by remember { mutableIntStateOf(2) }

Stepper(
    value = value,
    onValueChange = { value = it },
    minValue = 0,
    maxValue = 10,
)

Properties

Stepper

PropertyTypeDescriptionDefault ValueRequired
valueIntCurrent value-Yes
onValueChange(Int) -> UnitCallback with the new value on step-Yes
modifierModifierModifier applied to the stepperModifierNo
minValueIntMinimum reachable valueInt.MIN_VALUENo
maxValueIntMaximum reachable valueInt.MAX_VALUENo
stepIntIncrement/decrement per press1No
enabledBooleanWhether the stepper is enabledtrueNo
colorsStepperColorsColor configurationStepperDefaults.stepperColors()No

StepperDefaults

ConstantTypeDefault Value
ButtonSizeDp32.dp
GlyphSizeDp15.2.dp
GlyphStrokeWidthDp1.6.dp
SpacingDp12.dp
IndicatorMinWidthDp44.dp

stepperColors() factory

ParameterTypeDefault
buttonColorColorCOUITheme.colorScheme.secondaryContainer
contentColorColorCOUITheme.colorScheme.onSurface
disabledContentColorColorCOUITheme.colorScheme.disabledOnSurface

Behavior

  • Pressing − or + changes the value by step, clamped to [minValue, maxValue].
  • A button is automatically disabled when the value reaches its bound.
  • Each successful step fires the COUI step haptic (OPLUS constant 308 on ColorOS, the closest standard haptic elsewhere).

Changelog

Released under the Apache-2.0 License