Stepper input
Lab componentStepper input
StepperInput
displays a default numeric value that users can increase or decrease using the controls or by keyboard actions. Users can also manually enter a specific value. This is particularly useful in scenarios where users need to make small adjustments to a value within a defined range.
Stepper input has an increment step value of 1 and a step block value of 10, and you can only use it to accept numeric characters.
The component comes in two variants: primary and secondary. The primary variant is the default. To switch to the secondary variant, use variant="secondary"
.
When choosing between the primary and secondary variants, consider the background color on which the component will be placed.
To style the stepper input with a full border, set bordered={true}
. This styling is ideal when the input field uses the same fill color as the background, such as a primary fill color on a primary background.
The stepper input can show validation states—error, warning, and success—by using the validationStatus
prop.
- Use the error state to alert the user of a critical issue that’s related to the input. This issue, which may jeopardize completion of the task, usually requires action from the user to resolve the error.
- Display the warning state when you need to alert the user of a potential issue—that won’t prevent the user from continuing with the task, but may cause errors if it’s not addressed.
By default, the Stepper Input accepts values with zero decimal places. If a user needs to enter a value with decimals, such as a monetary amount, the number of decimal places can be customized.
If the user enters a value that doesn't match the specified decimal places, the component will adjust the value to the correct number of decimal places when it loses focus. For example, if the component is set to accept two decimal places and the user enters "12," the displayed value will be "12.00."
The component will also round the value up or down as necessary to match the specified number of decimal places.
The number of decimal places should be suitable for the specific use case. For instance, avoid accepting three decimal places when a retail user is dealing with currencies like pounds sterling or U.S. dollars, which typically require only two decimal places.
If you need to limit the range of accepted values, you’re able to set a maximum or minimum (or both).
- Clearly state the accepted value range in the form field’s helper text.
- Use the form field error state to inform users who manually type in a value outside the accepted range that the value is invalid.
Customize the default, increment and block values to suit your use case.
- Pick a default value that reflects the desired value for most users, such as the most frequently submitted number.
- Make sure you set an increment value that’s appropriate for the context. For example, if the user needs to enter ”Number of people”, adjustments of 0.5 would be confusing. If you’re undecided, consider using an increment value of 1.
You can use Button at the end of the input field with the endAdornment
prop. Buttons can allow for custom interactivity within the input field itself. Examples include:
Refresh adornment:
Reset the input to it’s default value, using the refresh button.
Sync adornment:
Sync to a live value from a source that is constantly changing, for example, when dealing with live stock prices. The component's value doesn't automatically update when the live value changes, however. In this case, the sync button automatically appears when the displayed value and live value don’t match.
Custom buttons:
Customize the positioning and appearance of the stepper buttons to meet specific product requirements or restrictions.
You can disable a stepper input, resulting in no action when the user interacts with it.
You can set stepper input to a read-only state. The user can't edit the value text in this state, but they can highlight and copy it.
By default, the marker is an em dash. If your application requires a different marker, you can set it via the emptyReadOnlyMarker
prop.
Use the read-only state when the user needs the value for their flow or current task but cannot edit it, for example, because of user permissions.
To aid visual flow, the numeric value sits directly beneath the label and other form field elements, which are left aligned by default. If you need to change the stepper input’s alignment to suit your particular use case or layout, you can configure it to be right or center aligned.
Use the textAlign
prop to change the alignment to “center” or “right.”
- Numeric values often have right alignment to make comparing them easier. However, sometimes number fields don't relate to each other or mix with text fields in a form, so left alignment may promote better visual flow.
- You may choose to center-align an input field to bring emphasis to a value. However, this should be the exception, and you should use it sparingly.
Stepper input has an increment step value of 1 and a step block value of 10, and you can only use it to accept numeric characters.
The component comes in two variants: primary and secondary. The primary variant is the default. To switch to the secondary variant, use variant="secondary"
.
When choosing between the primary and secondary variants, consider the background color on which the component will be placed.
To style the stepper input with a full border, set bordered={true}
. This styling is ideal when the input field uses the same fill color as the background, such as a primary fill color on a primary background.
The stepper input can show validation states—error, warning, and success—by using the validationStatus
prop.
- Use the error state to alert the user of a critical issue that’s related to the input. This issue, which may jeopardize completion of the task, usually requires action from the user to resolve the error.
- Display the warning state when you need to alert the user of a potential issue—that won’t prevent the user from continuing with the task, but may cause errors if it’s not addressed.
By default, the Stepper Input accepts values with zero decimal places. If a user needs to enter a value with decimals, such as a monetary amount, the number of decimal places can be customized.
If the user enters a value that doesn't match the specified decimal places, the component will adjust the value to the correct number of decimal places when it loses focus. For example, if the component is set to accept two decimal places and the user enters "12," the displayed value will be "12.00."
The component will also round the value up or down as necessary to match the specified number of decimal places.
The number of decimal places should be suitable for the specific use case. For instance, avoid accepting three decimal places when a retail user is dealing with currencies like pounds sterling or U.S. dollars, which typically require only two decimal places.
If you need to limit the range of accepted values, you’re able to set a maximum or minimum (or both).
- Clearly state the accepted value range in the form field’s helper text.
- Use the form field error state to inform users who manually type in a value outside the accepted range that the value is invalid.
Customize the default, increment and block values to suit your use case.
- Pick a default value that reflects the desired value for most users, such as the most frequently submitted number.
- Make sure you set an increment value that’s appropriate for the context. For example, if the user needs to enter ”Number of people”, adjustments of 0.5 would be confusing. If you’re undecided, consider using an increment value of 1.
You can use Button at the end of the input field with the endAdornment
prop. Buttons can allow for custom interactivity within the input field itself. Examples include:
Refresh adornment:
Reset the input to it’s default value, using the refresh button.
Sync adornment:
Sync to a live value from a source that is constantly changing, for example, when dealing with live stock prices. The component's value doesn't automatically update when the live value changes, however. In this case, the sync button automatically appears when the displayed value and live value don’t match.
Custom buttons:
Customize the positioning and appearance of the stepper buttons to meet specific product requirements or restrictions.
You can disable a stepper input, resulting in no action when the user interacts with it.
You can set stepper input to a read-only state. The user can't edit the value text in this state, but they can highlight and copy it.
By default, the marker is an em dash. If your application requires a different marker, you can set it via the emptyReadOnlyMarker
prop.
Use the read-only state when the user needs the value for their flow or current task but cannot edit it, for example, because of user permissions.
To aid visual flow, the numeric value sits directly beneath the label and other form field elements, which are left aligned by default. If you need to change the stepper input’s alignment to suit your particular use case or layout, you can configure it to be right or center aligned.
Use the textAlign
prop to change the alignment to “center” or “right.”
- Numeric values often have right alignment to make comparing them easier. However, sometimes number fields don't relate to each other or mix with text fields in a form, so left alignment may promote better visual flow.
- You may choose to center-align an input field to bring emphasis to a value. However, this should be the exception, and you should use it sparingly.
Stepper input has an increment step value of 1 and a step block value of 10, and you can only use it to accept numeric characters.
The component comes in two variants: primary and secondary. The primary variant is the default. To switch to the secondary variant, use variant="secondary"
.
When choosing between the primary and secondary variants, consider the background color on which the component will be placed.
To style the stepper input with a full border, set bordered={true}
. This styling is ideal when the input field uses the same fill color as the background, such as a primary fill color on a primary background.
The stepper input can show validation states—error, warning, and success—by using the validationStatus
prop.
- Use the error state to alert the user of a critical issue that’s related to the input. This issue, which may jeopardize completion of the task, usually requires action from the user to resolve the error.
- Display the warning state when you need to alert the user of a potential issue—that won’t prevent the user from continuing with the task, but may cause errors if it’s not addressed.
By default, the Stepper Input accepts values with zero decimal places. If a user needs to enter a value with decimals, such as a monetary amount, the number of decimal places can be customized.
If the user enters a value that doesn't match the specified decimal places, the component will adjust the value to the correct number of decimal places when it loses focus. For example, if the component is set to accept two decimal places and the user enters "12," the displayed value will be "12.00."
The component will also round the value up or down as necessary to match the specified number of decimal places.
The number of decimal places should be suitable for the specific use case. For instance, avoid accepting three decimal places when a retail user is dealing with currencies like pounds sterling or U.S. dollars, which typically require only two decimal places.
If you need to limit the range of accepted values, you’re able to set a maximum or minimum (or both).
- Clearly state the accepted value range in the form field’s helper text.
- Use the form field error state to inform users who manually type in a value outside the accepted range that the value is invalid.
Customize the default, increment and block values to suit your use case.
- Pick a default value that reflects the desired value for most users, such as the most frequently submitted number.
- Make sure you set an increment value that’s appropriate for the context. For example, if the user needs to enter ”Number of people”, adjustments of 0.5 would be confusing. If you’re undecided, consider using an increment value of 1.
You can use Button at the end of the input field with the endAdornment
prop. Buttons can allow for custom interactivity within the input field itself. Examples include:
Refresh adornment:
Reset the input to it’s default value, using the refresh button.
Sync adornment:
Sync to a live value from a source that is constantly changing, for example, when dealing with live stock prices. The component's value doesn't automatically update when the live value changes, however. In this case, the sync button automatically appears when the displayed value and live value don’t match.
Custom buttons:
Customize the positioning and appearance of the stepper buttons to meet specific product requirements or restrictions.
You can disable a stepper input, resulting in no action when the user interacts with it.
You can set stepper input to a read-only state. The user can't edit the value text in this state, but they can highlight and copy it.
By default, the marker is an em dash. If your application requires a different marker, you can set it via the emptyReadOnlyMarker
prop.
Use the read-only state when the user needs the value for their flow or current task but cannot edit it, for example, because of user permissions.
To aid visual flow, the numeric value sits directly beneath the label and other form field elements, which are left aligned by default. If you need to change the stepper input’s alignment to suit your particular use case or layout, you can configure it to be right or center aligned.
Use the textAlign
prop to change the alignment to “center” or “right.”
- Numeric values often have right alignment to make comparing them easier. However, sometimes number fields don't relate to each other or mix with text fields in a form, so left alignment may promote better visual flow.
- You may choose to center-align an input field to bring emphasis to a value. However, this should be the exception, and you should use it sparingly.