@gfazioli/mantine-select-stepper
Mantine SelectStepper is a React component that allows users to navigate through a list of options using increment and decrement buttons, providing an intuitive alternative to traditional dropdown selects for cycling through predefined values.
Installation
After installation import package styles at the root of your application:
You can import styles within a layer @layer mantine-select-stepper by importing @gfazioli/mantine-select-stepper/styles.layer.css file.
Usage
This is a description
React
Angular
Vue
Svelte
Ember
Controlled
The SelectStepper component can be fully controlled through the value prop. Use onChange handler to update the value:
React
Vue
Angular
onChange handler
onChange is called with two arguments:
value- string value of the selected optionoption– selected option object
If you prefer object format in state, use second argument of onChange handler:
Loop
Enable infinite scrolling by setting the loop prop. When enabled, the stepper will wrap around to the beginning when reaching the end, and vice versa.
React
Vue
Angular
Svelte
Solid
React
Vue
Angular
Svelte
Solid
React
Vue
Angular
Svelte
Solid
Disabled items
You can disable specific items in the data array. Disabled items will be skipped when navigating through the options.
React
Vue
Angular
Svelte
Solid
Disabled state
Set the disabled prop to disable the entire component. This will prevent any interaction with the stepper.
React
Vue
Angular
Custom icons
Customize the left and right icons using the leftIcon and rightIcon props. You can use any React node as an icon.
16GB
32GB
64GB
128GB
256GB
Custom width
Adjust the viewport width using the viewWidth prop. This controls how much space is allocated for displaying the current value.
Short
Medium Width
Very Long Item Name
With border
Add a border to the component using the withBorder prop.
React
Vue
Angular
React
Vue
Angular
Animation
Control the animation behavior with the animate, animationDuration, and animationTimingFunction props. You can create custom timing functions for unique effects, or disable animations entirely.
Fast
Normal
Slow
Bouncy
Instant
Switch
No Animation
Keyboard navigation
SelectStepper supports keyboard navigation:
ArrowLeftorArrowDown- Move to previous itemArrowRightorArrowUp- Move to next item
Custom rendering
renderOption prop
Use the renderOption prop to customize how each option is displayed. This function receives a ComboboxItem object and should return a React node. This is useful when you want to add additional visual elements like badges, icons, or custom formatting to your options.
Custom data with extended properties
You can extend the ComboboxItem interface to include additional properties in your data. When using the onChange handler, the second argument will contain the complete option object with all custom properties. This is perfect for storing metadata alongside your options.
{
"value": "vue",
"label": "Vue.js",
"version": "3.2.37",
"color": "green"
}Styles API
SelectStepper supports Styles API, you can add styles to any inner element of the component with classNames prop. Follow Styles API documentation to learn more.
This is a description
Hello
This is an error
Component Styles API
Hover over selectors to highlight corresponding elements
Use in forms
SelectStepper integrates seamlessly with other Mantine form components. It works well alongside inputs, selects, and other form controls, making it perfect for multi-step forms or configuration panels.
16GB
32GB
64GB
Boolean stepper pattern
The SelectStepper can be effectively used as a boolean toggle by combining several features. This pattern is useful when you want to create an interactive on/off switch with enhanced visual feedback.
Key features demonstrated in this example:
- Dynamic Icons: The
leftIconandrightIconprops change based on the current value, providing visual context - Custom Rendering: The
renderOptionprop displays the option as a colored badge (green for enabled, red for disabled) - Loop Navigation: With
loopenabled, users can continuously toggle between the two states - Controlled State: The component maintains the boolean value as a string ('true' or 'false')
This pattern is particularly useful for:
- Security settings (enable/disable features)
- Feature flags and toggles
- Binary choices with visual distinction
- Settings that benefit from explicit labeling of both states
Use cases
SelectStepper is particularly useful in scenarios where you have a limited set of sequential options and want to provide an intuitive navigation experience:
- Settings and Preferences: Choose between predefined options like theme modes (Light/Dark/Auto), text sizes (Small/Medium/Large), or quality levels (Low/Medium/High)
- Step-by-step Wizards: Navigate through sequential steps in a form or configuration process
- Rating Systems: Select ratings or levels (Beginner/Intermediate/Advanced, or 1-5 stars)
- Time Selection: Choose between time slots, hours, or predefined time intervals
- Difficulty Levels: Select game difficulty, exercise intensity, or skill levels
- Priority Selection: Choose task priorities (Low/Medium/High/Critical)
- Size Selection: Pick product sizes (XS/S/M/L/XL) in e-commerce applications
- View Modes: Switch between different view layouts (List/Grid/Table)
- Playback Speed: Control media playback speed (0.5x/1x/1.5x/2x)
- Zoom Levels: Select predefined zoom percentages (50%/75%/100%/125%/150%)
The component is especially effective when:
- The number of options is relatively small (typically 3-10 items)
- Options have a natural sequential order
- Users benefit from seeing the current selection prominently
- Space is limited and a traditional select dropdown would be too large
- You want to encourage exploration of available options through keyboard or button navigation