Note: There are deprecated versions of this component. Switch to a version of the docs older than 10.0.x to view their docs.
Examples
Check out the Usage section for details about how and when to use the NumberInput
component.
NumberInput
component only needs the label
property to be displayed. Other props can be used to complement its behavior: placeholder
, secondaryLabel
, onChange
... or the number specific ones.
<NumberInput
label="Number input component"
placeholder="Write what you want here"
secondaryLabel="Free text input"
/>
Max and min
NumberInput
allows setting up the max and min values. However, this is not related to a validation feature but to the component behavior. When setting any of these two properties, it will not be possible to use the component arrows to set a value that is lower than the min
prop or a value that is higher than the max
prop.
If specific validation is needed, it will need to be handled by the developer. For some details see the Text input validation on change section.
<NumberInput
label="Number input component with min and max"
placeholder="Enter a value"
secondaryLabel="Test the limits with using the arrows"
min={20}
max={40}
/>
Decimal places
decimalPlaces
allows to specify how many decimal values must be displayed. By default, no restriction is applied and any value entered by the user will be displayed. However, if this property is set (only accepts values from 0 to 100), the value displayed will be modified.
If specific validation is needed, it will need to be handled by the developer. For some details see the Text input validation on change section.
<NumberInput
label="Number input component limited decimals"
placeholder="Enter a value"
secondaryLabel="Try to add an additional decimal"
initialValue={5.67}
decimalPlaces={2}
/>
/>
Number input validation on change
NumberInput
does not provide a specific validation logic but it provides the way to include the developer validation and use the stateMessages
property to display any required error message.
This is an example of handling validation when onChange
event is triggered.
export function NumberInputValidation() {
const [validationMessages, setValidationMessages] = useState({});
const max = 100;
const min = 0;
const onChange = useCallback((e, newValue) => {
setValidationMessages({});
if (newValue && (newValue > max || newValue < min)) {
setValidationMessages({
error: ['Value must be between 0 and 100'],
});
}
}, []);
return (
<NumberInput
label="Enter value"
secondaryLabel="Min = 0. Max = 100"
stateMessages={validationMessages}
min={min}
max={max}
onChange={onChange}
/>
);
}
Note: There are deprecated versions of this component. Switch to a version of the docs older than 10.0.x to view their docs.
Usage
Overview
The number input enables users to enter or select numeric values within a predetermined range. It includes controls to incrementally increase or decrease the value. Users can also type numeric values directly into the input field.
When to use
To input a numeric value and incrementally increase or decrease the value.
When not to use
When the precise value doesn't matter to the user, but rather only the approximate range. Consider using the slider component instead.
Anatomy

- Label: describes the purpose of an input field.
- Helper text (optional): Provides extra context, hints, or helpful information to aid the user. Often used to explain specific requirements for correctly filling out a field.
- Numeric value: changes when the user enters a value into the field or uses the two arrows at the end of the input to add and subtract values.
- Number input field: the container, consisting of a fill and a stroke, in which the user enters data.
Content
General writing guidelines
- Use sentence case for all aspects of designing Guidewire product interfaces. Don't use title case.
- Use present tense verbs and active voice in most situations.
- Use common contractions to lend your copy a more natural and informal tone.
- Use plain language. Avoid unnecessary jargon and complex language.
- Keep words and sentences short.
Include a label
Place a clear, visible label outside the number input field. An input field without a label is ambiguous and not accessible.
Do position a permanent label outside the field.
Don't assume that the field is self-explanatory without a label.
Use help text
Use help text to provide guidance about what to input and how. Here are some examples of what you might include in help text:
- Context to aid the user, such as how the information will be used
- Hints for what kind of information goes inside the input field
- Formatting examples or requirements
Only use help text for pertinent information. Avoid using help text that simply restates the same information that appears in the label.
Use sentence case for help text. Write the help text as 1-2 short, complete sentences that end with a period. When showing formatting examples, you don't need to end with a period.
Do use help text to provide additional aid or context to the user.
Don't use help text to simply restate the same information that appears in the label.
Don't use placeholder text
Don't put placeholder text in the number entry field. Placeholder text strains users' short-term memory because it disappears once a value is entered. It also poses additional burdens for users with visual and cognitive impairments.
Instead, place hints and instructions, including formatting examples and requirements, outside of the field.
Source: Nielsen Norman Group
Do place hints and instructions, including formatting examples and requirements, outside of the field.
Don't add placeholders to the number entry field.
Use error text to guide users
Error message text tells a user how to fix the error. In the case of the number input field, errors are often related to something that must be fixed for in-line validation. For example, if the user doesn't fill out a required field that asks for their estimated annual mileage, you can use error text to guide them to a solution: “Enter your estimated annual mileage.”
Use sentence case for error text. Write 1-2 short, complete sentences that end with a period.
Do use error text to guide the user and show them a solution.
Don't write ambiguous error messages or leave users guessing as to how to resolve a problem.
Mark required fields
Use an asterisk (*) to indicate required fields. The asterisk precedes the field label. This helps users to easily locate which fields are required by scanning just the left-most character of the label.
Do use an asterisk to indicate that a field is required.
Don't use an asterisk to denote anything that is optional.
Use sentence case
Field labels appear in sentence case.
Refer to the UI text style guide for more information on how to implement sentence case.
Don't use title case. It hinders readability.
Behaviors
States
The number input field appears with no value (default), placeholder text, or a filled input.
Visual | State | Description |
---|
 | No value (default) | Indicates to the user that no value has been entered and there is no placeholder. |
 | Placeholder | Indicates to the user that no value has been entered. The placeholder is grayed out. |
 | Filled input | Indicates to the user that the input is filled with data. |
Number input fields also have interactive states for enabled, focus, disabled, error, read-only, and display-only.

State | Description |
---|
Enabled | Indicates to the user that the element is enabled for interaction. |
Focus | Indicates to the user which UI element in the system is focused. |
Disabled | Indicates to the user that the input value can't be changed because of local factors. For example, a checkbox above the input field must be checked to access this input field. The user can take action to enable it by interacting with the page. |
Error | Indicates that the user has made a validation error. Error text provides corrective feedback to users. |
Read-only | Indicates to the user that the input value can't be changed because of outside factors. For example, lack of write access. The user can take action to enable it by, for example, contacting an administrator. |
Display-only | The display-only state is used for two cases: - A UI element is used in display mode.
- A UI element is displayed in edit mode, but is never editable.
This state was called “read-only” before. |
Interactions
Mouse
Users can activate a number input by clicking in the area inside border. When focused, two arrows appear at the end of the input. These controls enable users to incrementally increase or decrease the value.

Keyboard
The input element is keyboard accessible. Users can navigate into and out of the component using the TAB key.
Screenreader
The number input component derives its accessible name via an aria-label
attribute. Changing the text value of the label element also changes the value of the accessible name. The default aria-required='true'
attribute toggles to 'false' when the required checkbox is checked in Storybook.
Accessibility
This component adheres to the following criteria for color and zoom accessibility:
- Color: The contrast ratio of textual elements against their background is above 4.5:1.
- Zoom: All content is visible and functional up to and including a zoom factor of 200%.
This component has been validated to meet the WCAG 2.0 AA accessibility guidelines. However, changes made by the content author can affect accessibility conformance. When using this component within your application, ensure that labels and instructions are meaningful and concise. Provide supplemental instructions if necessary.
Note: There are deprecated versions of this component. Switch to a version of the docs older than 10.0.x to view their docs.
Code
<NumberInput
label="Number input component"
step={5}
max={100}
min={0}
/>
Import statement
import { NumberInput } from '@jutro/components';
Component contract
Make sure to understand the Design System components API surface, and the implications and trade-offs. Learn more in our introduction to the component API.
Properties
label
required
DescriptionLabel associated with input field, also passed as a default value to aria-label
className
DescriptionCSS class passed to root element of the component
decimalPlaces
DescriptionThe number of decimal places to display in the value. If not set, no restriction is applied.
disabled
DescriptionIf true, component is rendered in disabled state
displayOnly
DescriptionIf true, displays the component value as a plain text. Consider using readonly
instead, if possible, because plain text has much worse accessibility than readonly inputs
hideGrouping
DescriptionIf true,hides the thousands separator
hideLabel
DescriptionIf true, the label is not visible
initialValue
DescriptionInitial value of input. If value prop is specified along with this prop, this prop's value is discarded.
labelPosition
DescriptionAllows to select label position
max
DescriptionMax value of input. If this prop is passed, component does not allow to enter values, higher than specified one by using arrow up key/button.
min
DescriptionMin value of input. If this prop is passed, component does not allow to enter values, lower than specified one by using arrow down key/button.
onChange
DescriptiononChange callback. Gets event as first argument and parsed input value as a second argument
placeholder
DescriptionPlaceholder to display on an empty component
readOnly
DescriptionIf true, component is rendered in read-only state. For value as a plain text consider using displayOnly
required
DescriptionIf true, component is rendered as required and label has asterisk.
secondaryLabel
DescriptionSecondary label text to display
stateMessages
DescriptionObject with input state and messages that should be shown for current state
step
DescriptionStep value for value change. If this prop is passed, component will increase/decrease it's value on step when user press arrow key or button.
Type`{ text: IntlMessageShape, trigger: string }`
DescriptionTooltip props object: text - to show tooltip content, trigger - to set tooltip trigger
value
DescriptionValue of input. Takes precedence over initialValue. If this prop is passed, component works in controlled mode and its value will change only if this prop changes.
Hooks
No hooks are available for NumberInput.
Translation keys
There are only 2 translation keys associated to the NumberInput
component, both of them related to the aria-label
default text:
Key | Used for |
---|
jutro-components.fields.NumberInput.increment | aria-label for the 'up' arrow button |
jutro-components.fields.NumberInput.decrement | aria-label for the 'down' arrow button |
Escape Hatches
For more information, see our documentation about escape hatches.
The following options are available:
- Design Tokens
className
property
- Passing native HTML attributes
- Ref with imperative handlers
- Native event property
Passing HTML properties to the component
You can use HTML input attributes, except any of the ones which are overridden by Jutro. These attributes will be assigned to the HTML input
element.
Please note that the most number input specific attributes (step
, min
and max
) are included as part of the component API and might have some Jutro specific logic associated.
<NumberInput
label="Number input component"
id="numberID1"
/>
The result of passing this id
property will be that it will be part of the HTML input
that is created in the HTML DOM.
Ref with imperative handlers
Jutro inputs have implemented imperative handlers as a mechanism to provide access to some common native features that might be useful for you. The following features are available:
-
Set focus to allow you to set the user focus into a specific component
-
Blur to remove the focus from the component
-
Scroll to the component so that you can take the user to a specific area of the page.
These features are provided through the ref
property, which exposes them as follows:
const componentRef = useRef(null);
const setFocus = () => {
componentRef?.current.focus();
}
const removeFocus = () => {
componentRef?.current.blur();
}
const scrollToComponent = () => {
componentRef?.current.scrollIntoView();
}
<Component ref={componentRef}>
More options might be included in the future.
Custom behaviors