Number Stepper

A numeric input with increment/decrement buttons, min/max bounds, step intervals, and custom formatting.

Import

import { NumberStepper } from 'heroui-native';

Anatomy

<NumberStepper>
  <NumberStepper.DecrementButton />
  <NumberStepper.Value />
  <NumberStepper.IncrementButton />
</NumberStepper>
  • NumberStepper: Root container that manages numeric value state, and provides context to sub-components. Supports both controlled and uncontrolled modes.
  • NumberStepper.DecrementButton: Pressable button that decreases the value by one step. Auto-disables at the minimum boundary. Renders a minus icon by default.
  • NumberStepper.Value: Displays the current numeric value with direction-aware flip animations on change.
  • NumberStepper.IncrementButton: Pressable button that increases the value by one step. Auto-disables at the maximum boundary. Renders a plus icon by default.

Usage

Basic Usage

The NumberStepper component uses compound parts to create a numeric stepper control.

<NumberStepper>
  <NumberStepper.DecrementButton />
  <NumberStepper.Value />
  <NumberStepper.IncrementButton />
</NumberStepper>

Custom Step

Configure the increment/decrement amount per press.

<NumberStepper defaultValue={0} step={5} minValue={0} maxValue={100}>
  <NumberStepper.DecrementButton />
  <NumberStepper.Value />
  <NumberStepper.IncrementButton />
</NumberStepper>

<NumberStepper defaultValue={0} step={0.5} minValue={0} maxValue={5}>
  <NumberStepper.DecrementButton />
  <NumberStepper.Value />
  <NumberStepper.IncrementButton />
</NumberStepper>

Disabled

Disable the entire number stepper or let boundaries auto-disable individual buttons.

<NumberStepper defaultValue={3} isDisabled>
  <NumberStepper.DecrementButton />
  <NumberStepper.Value />
  <NumberStepper.IncrementButton />
</NumberStepper>

Controlled

Control the value externally with value and onValueChange.

const [value, setValue] = useState(5);

<NumberStepper value={value} onValueChange={setValue} minValue={0} maxValue={20}>
  <NumberStepper.DecrementButton />
  <NumberStepper.Value />
  <NumberStepper.IncrementButton />
</NumberStepper>;

Render Function Children

Use a render function to access number stepper state for conditional rendering.

<NumberStepper
  value={quantity}
  onValueChange={setQuantity}
  minValue={1}
  maxValue={99}
>
  {({ isAtMin }) => (
    <>
      <NumberStepper.DecrementButton
        keepActiveAtBoundary
        onPress={() => {
          if (isAtMin) {
            Alert.alert('Removed', 'Item removed from cart');
          }
        }}
      >
        {isAtMin ? <TrashIcon size={16} /> : undefined}
      </NumberStepper.DecrementButton>
      <NumberStepper.Value />
      <NumberStepper.IncrementButton />
    </>
  )}
</NumberStepper>

Example

import { NumberStepper } from 'heroui-native';
import { useState } from 'react';
import { Alert, View } from 'react-native';

export default function NumberStepperExample() {
  const [quantity, setQuantity] = useState(1);

  return (
    <View className="flex-1 px-5 items-center justify-center">
      <NumberStepper
        value={quantity}
        onValueChange={setQuantity}
        minValue={1}
        maxValue={99}
      >
        {({ isAtMin }) => (
          <>
            <NumberStepper.DecrementButton
              keepActiveAtBoundary
              onPress={() => {
                if (isAtMin) {
                  Alert.alert('Removed', 'Item removed from cart');
                }
              }}
            >
              {isAtMin ? <TrashIcon size={16} /> : undefined}
            </NumberStepper.DecrementButton>
            <NumberStepper.Value />
            <NumberStepper.IncrementButton />
          </>
        )}
      </NumberStepper>
    </View>
  );
}

API Reference

NumberStepper

proptypedefaultdescription
childrenReact.ReactNode | ((props: NumberStepperRootRenderProps) => React.ReactNode)-Children elements or render function receiving number stepper state
valuenumber-Controlled numeric value
defaultValuenumber0Default value for uncontrolled mode
minValuenumber-InfinityMinimum allowed value
maxValuenumberInfinityMaximum allowed value
stepnumber1Step amount for increment/decrement operations
isDisabledbooleanfalseWhether the number stepper is disabled
classNamestring-Additional CSS classes for the root container
onValueChange(value: number) => void-Callback fired when the value changes
animationAnimationRootDisableAll-Animation configuration for the root component
...ViewPropsViewProps-All standard React Native View props are supported

NumberStepperRootRenderProps

proptypedescription
valuenumberCurrent numeric value of the number stepper
isAtMinbooleanWhether the current value is at or below the minimum
isAtMaxbooleanWhether the current value is at or above the maximum
isDisabledbooleanWhether the entire number stepper is disabled
stepnumberStep increment/decrement amount
minValuenumberMinimum allowed value
maxValuenumberMaximum allowed value

AnimationRootDisableAll

Animation configuration for the number stepper root component. Can be:

  • false or "disabled": Disable only root animations
  • "disable-all": Disable all animations including children
  • true or undefined: Use default animations

NumberStepper.DecrementButton

proptypedefaultdescription
childrenReact.ReactNode-Custom content for the button. Defaults to a minus icon
isDisabledboolean-Whether this button is individually disabled. Overrides context and boundary auto-disable
keepActiveAtBoundarybooleanfalseWhen true, the button stays interactive at the min boundary instead of auto-disabling
classNamestring-Additional CSS classes
iconPropsNumberStepperButtonIconProps-Props forwarded to the default minus icon. Ignored when children is provided
animationNumberStepperButtonAnimation-Animation configuration for the button press scale effect
isAnimatedStyleActivebooleantrueWhether animated styles (react-native-reanimated) are active
...PressablePropsPressableProps-All standard React Native Pressable props are supported

NumberStepper.Value

proptypedefaultdescription
childrenReact.ReactNode-Custom content to display instead of the default value text
classNamestring-Additional CSS classes for the value text
animationNumberStepperValueAnimation-Animation configuration for the value display
...Animated.TextPropsAnimated.TextProps-All Reanimated Animated.Text props are supported

NumberStepperValueAnimation

Animation configuration for the value component. Can be:

  • false or "disabled": Disable all animations
  • true or undefined: Use default animations
  • object: Custom animation configuration
proptypedefaultdescription
state'disabled' | boolean-Disable animations while customizing properties
enteringNumberStepperDirectionalAnimationDirection-aware Keyframe slide + scale, 400msEntering animation played when the new value mounts
exitingNumberStepperDirectionalAnimationDirection-aware Keyframe slide + scale, 400msExiting animation played when the old value unmounts
translateYDistancenumber16Vertical slide distance in pixels. Ignored when custom entering/exiting are provided
scaleValuenumber0.7Scale at the start/end of transitions. Ignored when custom entering/exiting are provided

NumberStepperDirectionalAnimation

A single animation or a per-direction pair. Pass a plain value to use the same animation for both directions, or an object with increase/decrease keys for direction-aware control.

typedescription
EntryOrExitLayoutTypeSingle animation used for both directions
{ increase?: EntryOrExitLayoutType; decrease?: EntryOrExitLayoutType }Per-direction animations

NumberStepper.IncrementButton

proptypedefaultdescription
childrenReact.ReactNode-Custom content for the button. Defaults to a plus icon
isDisabledboolean-Whether this button is individually disabled. Overrides context and boundary auto-disable
keepActiveAtBoundarybooleanfalseWhen true, the button stays interactive at the max boundary instead of auto-disabling
classNamestring-Additional CSS classes
iconPropsNumberStepperButtonIconProps-Props forwarded to the default plus icon. Ignored when children is provided
animationNumberStepperButtonAnimation-Animation configuration for the button press scale effect
isAnimatedStyleActivebooleantrueWhether animated styles (react-native-reanimated) are active
...PressablePropsPressableProps-All standard React Native Pressable props are supported

NumberStepperButtonIconProps

proptypedefaultdescription
sizenumber18Size of the icon in pixels
colorstringforegroundColor of the icon

NumberStepperButtonAnimation

Animation configuration for button press scale effect. Can be:

  • false or "disabled": Disable all animations
  • true or undefined: Use default animations
  • object: Custom animation configuration
proptypedefaultdescription
state'disabled' | boolean-Disable animations while customizing properties
valuenumber0.95Scale value applied when the button is pressed
timingConfigWithTimingConfig{ duration: 150 }Timing configuration for the scale transition

Hooks

useNumberStepper

Hook to access the number stepper root context. Must be used within a NumberStepper component.

import { useNumberStepper } from 'heroui-native';

const {
  value,
  isAtMin,
  isAtMax,
  isDisabled,
  step,
  minValue,
  maxValue,
  direction,
  decrement,
  increment,
} = useNumberStepper();

Returns

propertytypedescription
valuenumberCurrent numeric value of the number stepper
stepnumberStep increment/decrement amount
minValuenumberMinimum allowed value
maxValuenumberMaximum allowed value
isDisabledbooleanWhether the entire number stepper is disabled
isAtMinbooleanWhether the current value is at or below the minimum
isAtMaxbooleanWhether the current value is at or above the maximum
directionNumberStepperDirectionDirection of the most recent value change ('increase' or 'decrease')
decrement() => voidDecrement the value by one step
increment() => voidIncrement the value by one step

On this page