StylishNumberInput

fun StylishNumberInput(value: Int, onValueChange: (Int) -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true, range: IntRange = 0..Int.MAX_VALUE, step: Int = 1, label: String = "", isError: Boolean = false, errorMessage: String? = null, leadingIcon: @Composable () -> Unit? = null, trailingIcon: @Composable () -> Unit? = null, textStyle: TextStyle = MaterialTheme.typography.bodyLarge, shape: Shape = RoundedCornerShape(DefaultStylishDimensions.connectedCornerRadius), colors: TextFieldColors? = null, interactionSource: MutableInteractionSource? = null)

A numeric stepper input combining a text field with minus/plus buttons, for choosing an integer within range.

The value is hoisted — the caller owns the state via value and onValueChange. The field allows free typing: each edit is parsed as an Int (and coerced into range); edits that do not parse are rejected and the field snaps back to the previous value. The minus and plus buttons step the value by step and disable automatically at the bounds of range or when enabled is false. Since the field (through StylishFormTextField) is a Material 3 outlined text field, it carries M3's built-in focus indicator and error outline.

The field is wrapped in StylishFormTextField, which lays out label, supporting text, and error message below the field; the steppers flank it left and right. Use leadingIcon / trailingIcon for icons inside the field (e.g. a currency symbol or unit), which are independent of the steppers.

Testing

The root carries the default test tag stylish_numberinput for UI tests. Callers can override it by passing their own Modifier.testTag(...) in modifier.

Parameters

value

The current integer value (controlled state).

onValueChange

Called with the new value on every accepted edit and on every stepper tap. Values are coerced into range before being reported.

modifier

Modifier applied to the root Row.

enabled

When false, the field rejects input and the steppers are disabled.

range

The allowed value range. Steppers disable at the bounds; typed values are coerced into the range. Defaults to 0..Int.MAX_VALUE.

step

The amount added or removed by one stepper tap. Defaults to 1.

label

Label displayed above the field. Defaults to "", which renders no label region.

isError

When true, the field renders its error outline color.

errorMessage

Error text displayed below the field in the error color.

leadingIcon

Optional icon slot at the start of the field (the minus stepper sits outside the field).

trailingIcon

Optional icon slot at the end of the field (the plus stepper sits outside the field).

textStyle

Typography for the input text. Defaults to MaterialTheme.typography.bodyLarge.

shape

Shape of the field's outlined border. Defaults to RoundedCornerShape with DefaultStylishDimensions.connectedCornerRadius.

colors

Color scheme for the field. Defaults to OutlinedTextFieldDefaults.colors().

interactionSource

The MutableInteractionSource for the field, used to observe focus/press/hover interactions. When null, an internal one is remembered.