JengaStepper

fun JengaStepper(value: Int, onValueChange: (Int) -> Unit, modifier: Modifier = Modifier, min: Int = 0, max: Int = Int.MAX_VALUE, step: Int = 1, enabled: Boolean = true, decrementContentDescription: String? = null, incrementContentDescription: String? = null, valueLabel: (Int) -> String = { it.toString() }, colors: JengaStepperColors = JengaStepperDefaults.colors(), editable: Boolean = false, onRemove: () -> Unit? = null, removeContentDescription: String? = null, shape: Shape = JengaStepperDefaults.shape, buttonShape: Shape = JengaStepperDefaults.buttonShape, buttonSize: Dp = JengaTheme.components.stepper?.buttonSize ?: JengaStepperDefaults.ButtonSize, buttonElevation: Dp = JengaStepperDefaults.buttonElevation, trackPadding: Dp = JengaStepperDefaults.trackPadding, valueMinWidth: Dp = JengaTheme.components.stepper?.valueMinWidth ?: JengaStepperDefaults.ValueMinWidth, textStyle: TextStyle = JengaStepperDefaults.textStyle)(source)

A compact numeric stepper: a pill track with round decrement/increment buttons around a centered value. Replaces bare −/+ glyph pairs and gives both buttons real 48dp touch targets and content descriptions.

Generic and domain-neutral: use it for servings, quantities, household size, times, or any bounded integer. Colors and icons come from Jenga tokens.

With editable the value can also be typed; a typed number outside min..max is not applied. With onRemove, the decrement button becomes a remove button once another step down would pass min (e.g. a cart quantity).

Parameters

value

the current value.

onValueChange

called with the clamped new value when a button is tapped.

modifier

the Modifier for this stepper.

min

the inclusive lower bound; the decrement button disables at it.

max

the inclusive upper bound; the increment button disables at it.

step

the increment/decrement amount.

enabled

whether the whole control is interactive.

decrementContentDescription

accessibility label for the − button.

incrementContentDescription

accessibility label for the + button.

valueLabel

formats the centered value (e.g. to add a unit); not used while editable.

colors

the color set; defaults to JengaStepperDefaults.colors.

editable

whether the value can be typed.

onRemove

called when the remove button is tapped; null keeps a disabled − at min.

removeContentDescription

accessibility label for the remove button.

shape

the track shape.

buttonShape

the +/- button shape.

buttonSize

the +/- button size; defaults to the theme's value, else JengaStepperDefaults.ButtonSize.

buttonElevation

shadow under an enabled +/- button.

trackPadding

padding inside the track, around the buttons.

valueMinWidth

minimum width of the value; defaults to the theme's value, else JengaStepperDefaults.ValueMinWidth.

textStyle

the value text style.