Skip to main content

Number Stepper

StorybookView in Storybook

Explore interactive examples and all component variations in our Storybook.

The NumberStepper component provides an intuitive numeric input with increment and decrement buttons. Built with accessibility and precision in mind, it supports various sizes, step values, and symbol customization. Perfect for quantity selectors, price inputs, configuration settings, and any interface requiring precise numeric control.

Basic Usage

Current value: 5

Size Variants

Symbol Variants

$
%
kg
°C

Step Variations

$
%

E-commerce Example

Product Details
Premium T-Shirt$29.99
Total:$29.99

Disabled State

%
$

Properties

NumberStepper

PropertyTypeDefaultDescription
valuenumber-Current value (controlled).
defaultValuenumber0Initial value (uncontrolled).
onChange(value: number) => void-Callback fired when value changes.
minnumber-InfinityMinimum allowed value.
maxnumberInfinityMaximum allowed value.
stepnumber1Increment/decrement step size.
size'sm' | 'md' | 'lg' | 'xl''md'Size variant of the component.
disabledbooleanfalseWhether the component is disabled.
leftSymbolstring-Symbol displayed on the left side of input.
rightSymbolstring-Symbol displayed on the right side of input.
classNamestring-Additional CSS classes.

Size Specifications

SizeButtonInput HeightIcon Size
sm32px × 32px32px12px
md40px × 40px40px16px
lg48px × 48px48px20px
xl56px × 56px56px24px

Behavior

Value Management

  • Controlled - Use value and onChange for external state management
  • Uncontrolled - Use defaultValue for internal state management
  • Validation - Values are automatically clamped to min/max bounds

Input Handling

  • Direct Input - Users can type values directly into the input field
  • Button Controls - Plus/minus buttons for incremental changes
  • Keyboard Support - Arrow keys for increment/decrement
  • Focus Behavior - Input selects all text on focus

Symbol Positioning

  • Left Symbol - Positioned on the left side with appropriate padding
  • Right Symbol - Positioned on the right side with appropriate padding
  • Responsive - Symbol size adjusts based on component size

Accessibility

The NumberStepper component includes comprehensive accessibility features:

  • Keyboard Navigation - Arrow keys, Enter, and Tab support
  • Screen Reader Support - Proper ARIA labels and descriptions
  • Focus Management - Clear focus indicators and logical tab order
  • Button Labels - Descriptive aria-labels for increment/decrement buttons
  • Value Announcements - Changes announced to screen readers
  • Disabled State - Proper disabled state handling

Common Use Cases

The NumberStepper component is perfect for:

  • E-commerce - Product quantity selectors and pricing
  • Forms - Numeric input fields with validation
  • Settings - Configuration values and preferences
  • Gaming - Score inputs and game parameters
  • Financial - Currency amounts and percentages
  • Measurements - Weight, distance, and unit conversions
  • Time/Date - Duration and interval inputs
  • Inventory - Stock quantities and limits

Best Practices

  1. Appropriate Steps - Choose step values that make sense for your use case
  2. Clear Labels - Always provide descriptive labels for the input
  3. Reasonable Bounds - Set appropriate min/max values
  4. Symbol Usage - Use symbols that clearly indicate the value type
  5. Size Selection - Choose sizes that fit your interface design
  6. Validation - Provide clear feedback for invalid values
  7. Responsive Design - Test on different screen sizes
  8. Performance - Debounce onChange callbacks for expensive operations