Components · Forms · Number
Back to Number typesNumber
Use for collecting a single numeric value, like a quantity or age, optionally with stepper buttons to increment or decrement it.
Properties
Size, corner radius, label, placeholder and the stepper are properties of the same component, not separate fields - change them below to check this field's style and states in the Live Preview.
Live Preview
All 3 types compared side by side, each in all 6 states. One full matrix is rendered per selected combination of Size and Corner radius - check more than one option in a dropdown to see every combination side by side.
When to use
Any form field that collects a single numeric value - quantities, ages, prices, or counts.
Validation
Number carries a format contract on top of the usual required-field rules - what counts as a valid character, when an out-of-range value gets flagged, and how the error names the actual constraint.
- Required marking - mark a required Number field the same way as any other required field in this system (red asterisk after the label).
- Validation timing - reject non-numeric characters at input time, so a letter or symbol never lands in the field to begin with. Min/max/step range checks are different: validate those on blur, not on every keystroke - flagging "5" as too low while the user is still about to type "50" is hostile and simply wrong.
- Error message - name the actual constraint that failed: "Enter a value between 1 and 100" or "Must be a multiple of 5," never a generic "Invalid number."
- Recovery - when the stepper is shown, clicking +/- from an out-of-range value snaps it to the nearest valid boundary, giving the user a one-click fix instead of forcing a full retype.
Component Guide
Overview
Number is a text field restricted to numeric input, optionally paired with stepper buttons to increment or decrement the value by a fixed amount - used anywhere the value is fundamentally a quantity rather than arbitrary text.
When to Use
- A quantity someone adjusts up or down - cart quantity, guest count.
- Any purely numeric value - age, price, a rating count.
- A bounded value with a sensible min/max and step - where steppers make small adjustments faster than typing.
When Not to Use
- A number that's really an identifier, not a quantity - a phone number, a ZIP/postal code, a credit card number - use Input, since these are never incremented/decremented and often contain formatting characters.
- A value that should be picked from a fixed list - use Select.
- A range of two numbers - consider Slider for a bounded range with no need for exact keyboard entry.
Best Practices
- Set sensible min/max/step values that match the real-world constraint (e.g. quantity can't go below 1).
- Keep the stepper buttons a secondary input method - typing a value directly should always work too.
- Show units alongside the field (e.g. "kg", "$") rather than expecting the number alone to communicate meaning.
Do and Don't
Do
1 to 20 per order.
Steppers for a small count the user nudges, with the permitted range stated up front.
Don't
Steppers on a value in the tens of thousands are useless - nobody clicks up from zero. Drop them when the step is not a unit the user thinks in.
Accessibility
- Uses the native numeric input semantics so mobile keyboards default to a numeric layout automatically.
- Stepper buttons are separately focusable and labeled ("Increase quantity" / "Decrease quantity"), not just plus/minus icons.
- Min/max boundaries are announced or otherwise communicated, not just silently enforced.
Related Components
Input, Slider, Rating.
{
"component": "Number",
"category": "Forms",
"summary": "Number is a text field restricted to numeric input, optionally paired with stepper buttons to increment or decrement the value by a fixed amount - used anywhere the value is fundamentally a quantity rather than arbitrary text.",
"whenToUse": [
"A quantity someone adjusts up or down - cart quantity, guest count.",
"Any purely numeric value - age, price, a rating count.",
"A bounded value with a sensible min/max and step - where steppers make small adjustments faster than typing."
],
"whenNotToUse": [
"A number that's really an identifier, not a quantity - a phone number, a ZIP/postal code, a credit card number - use Input, since these are never incremented/decremented and often contain formatting characters.",
"A value that should be picked from a fixed list - use Select.",
"A range of two numbers - consider Slider for a bounded range with no need for exact keyboard entry."
],
"bestPractices": [
"Set sensible min/max/step values that match the real-world constraint (e.g. quantity can't go below 1).",
"Keep the stepper buttons a secondary input method - typing a value directly should always work too.",
"Show units alongside the field (e.g. \"kg\", \"$\") rather than expecting the number alone to communicate meaning."
],
"doAndDont": {
"do": "Steppers for a small count the user nudges, with the permitted range stated up front.",
"dont": "Steppers on a value in the tens of thousands are useless - nobody clicks up from zero. Drop them when the step is not a unit the user thinks in."
},
"accessibility": [
"Uses the native numeric input semantics so mobile keyboards default to a numeric layout automatically.",
"Stepper buttons are separately focusable and labeled (\"Increase quantity\" / \"Decrease quantity\"), not just plus/minus icons.",
"Min/max boundaries are announced or otherwise communicated, not just silently enforced."
],
"relatedComponents": [
"Input",
"Slider",
"Rating"
]
}