Number Input
Number Inputs allow users to enter numeric data.
Anatomy

- Label: Title of the Number Input.
- Input Container: Rectangular container that houses placeholder and input text.
- Placeholder/Input Text: Placeholder text is optional and shows an example of how to format the text for the input required.
- Percent Symbol: (Optional) Only used to provide context around the intent of the input. These elements are not editable by the user.
Usage Guidance
When to Use
- When numeric data needs to be entered, such as: quantities, counts, zip codes, percentages, decimals, etc.

Do
Numeric data containing decimals or percentages are ideal for the number input

Don't
Don't use the number input for dates or time.
When to Consider Something Else
- Use a Text Input when the intended user input is all or partially text based.
- Use a Text Area when you need to let users enter an amount of text that’s longer than a single line.
- Use a Rich Text Editor if styling is needed, such as for configuring email messages.
- Consider using a Prompt, Radio or Checkboxes if there is predetermined data that a user should not input themselves
- When entering phone numbers use the dedicated Phone Number input, which provides additional controls and formatting specific to this type of data.
- Monetary data should use the Currency Input, which provides additional controls and formatting specific to this type of data.
- Date Inputs/pickers should be used for all date based data. These inputs are built for easier data entry and come with specific date formatting.
- Time Inputs/pickers should be used for all time based data. These inputs are built for easier data entry and come with specific time based formatting.
- For more information about different types of inputs, review the Form pattern.
Behaviors
Number Inputs follow all the same interaction and notifications state as our Text Input.
Keyboards
Mobile devices utilize on-screen keyboards. Typically it is up to the designer to specify the keyboard-type in their designs, however the number input will always default to the native number pad.

Screen Size Differences
Typically, inputs on mobile should stretch to the full width of the screen. However, there are some exceptions when providing smaller inputs to better set expectations for the input, such as providing a smaller input for entering a ZIP code. For larger mobile devices, inputs should have a maximum width of 600 pts to retain proper readability.
Examples
Number
The standard number input for most all numeric data. This supports decimals, and positive/negative numbers.

Percentage
The percentage variant appends a percent symbol (%) to the trailing end of the number string to provide additional meaning and context to the user. This also supports decimals, and positive/negative numbers.

API Guidelines
Methods
Class name: LabelledNumberInput Module name: UIComponentsPlugin
public init(
featureData: FeatureMetricsData,
input: Binding<String>,
unformattedOutput: Binding<String>,
allowNegative: Bool,
allowDecimal: Bool,
maxIntegerDigits: Int,
maxFractionDigits: Int,
isPercentageInput: Bool,
label: String,
helperText: String?,
context: Binding<SemanticContext>,
locale: Locale,
localizer: LocalizationAdapting,
onFocusChanged: ((Bool) -> Void)? = nil,
onSubmission: (() -> Void)? = nil
)Parameters
| Name | Description |
|---|---|
| featureData | the feature name/context and the screen ID in which the component appears. |
| input | Number string input. Normally start with empty string but can be any numeric string. This is what appears in the field. |
| unformattedOutput | Unformatted number string output i.e no group separators included. |
| allowNegative | Allow to input negative numbers. |
| allowDecimal | Allow to input decimal number. |
| maxIntegerDigits | Maximum number of digits for integer part. |
| maxFractionDigits | Maximum number of digits for fractional part. |
| isPercentageInput | Accepting input as percentage value. |
| label | Label to be positioned above field, already localized. |
| helperText | Helper text below field. Helper text will be prefixed with “Error:”/“Warning:” as part of this init. |
| context | SemanticContext of the field. |
| locale | Locale of the field to format the number. |
| localizer | localizer for the field. |
| onFocusChanged | Optional closure which allows you to listen to focus changes from the TextField. Default is nil. |
| onSubmission | Optional closure which allows you to listen to the onSubmit or Done button action from the TextField. Default is nil. |
Accessibility Guidelines
- Coming soon…
Content Guidelines
- Labels for Number Inputs are written in title case.
- Use helper text to instruct the user what the proper input may be.
- Use placeholder text only to provide examples of proper inputs. Never use placeholder text to help instruct users.
- For additional numeric content guidance review the Numbers section.
Anatomy

- Label: Title of the Number Input.
- Input Container: Rectangular container that houses placeholder and input text.
- Placeholder/Input Text: Placeholder text is optional and shows an example of how to format the text for the input required.
- Percent Symbol: (Optional) Only used to provide context around the intent of the input. These elements are not editable by the user.
Usage Guidance
When to Use
- When numeric data needs to be entered, such as: quantities, counts, zip codes, percentages, decimals, etc.

Do
Numeric data containing decimals or percentages are ideal for the number input

Don't
Don't use the number input for dates or time.
When to Consider Something Else
- Use a Text Input when the intended user input is all or partially text based.
- Use a Text Area when you need to let users enter an amount of text that’s longer than a single line.
- Use a Rich Text Editor if styling is needed, such as for configuring email messages.
- Consider using a Prompt, Radio or Checkboxes if there is predetermined data that a user should not input themselves
- When entering phone numbers use the dedicated Phone Number input, which provides additional controls and formatting specific to this type of data.
- Monetary data should use the Currency Input, which provides additional controls and formatting specific to this type of data.
- Date Inputs/pickers should be used for all date based data. These inputs are built for easier data entry and come with specific date formatting.
- Time Inputs/pickers should be used for all time based data. These inputs are built for easier data entry and come with specific time based formatting.
- For more information about different types of inputs, review the Form pattern.
Behaviors
Number Inputs follow all the same interaction and notifications state as our Text Input.
Keyboards
Mobile devices utilize on-screen keyboards. Typically it is up to the designer to specify the keyboard-type in their designs, however the number input will always default to the native number pad.

Screen Size Differences
Typically, inputs on mobile should stretch to the full width of the screen. However, there are some exceptions when providing smaller inputs to better set expectations for the input, such as providing a smaller input for entering a ZIP code. For larger mobile devices, inputs should have a maximum width of 600 pts to retain proper readability.
Examples
Number
The standard number input for most all numeric data. This supports decimals, and positive/negative numbers.

Percentage
The percentage variant appends a percent symbol (%) to the trailing end of the number string to provide additional meaning and context to the user. This also supports decimals, and positive/negative numbers.

API Guidelines
Methods
fun NumberInputUiComponent(
modifier: Modifier = Modifier,
label: String? = null,
value: String = "",
onValueChange: (String) -> Unit,
onClickClearTextIcon: (() -> Unit) = {},
placeholder: String? = null,
helperText: String? = null,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
isDecimal: Boolean = true,
isPercent: Boolean = false,
allowNegative: Boolean = true,
maximumIntegerDigits: Int = 100,
maximumDecimalDigits: Int = 100,
semanticState: SemanticState = SemanticState()
)Parameters
| Name | Description | Default values |
|---|---|---|
| label | The text above the input that typically designates the name of the component. | null |
| value | The text to be displayed inside of the number input. | "" |
| onValueChange | Callback lambda that is executed whenever the text of the input changes. | |
| onClickClearTextIcon | Callback lambda that is executed when the user clicks on the “clear text” icon that is displayed while the component is focused. | |
| placeholder | This text is shown inside of the input when the value is empty to provide a hint to the user. | null |
| helperText | Helper text is displayed underneath the input area that to give additional context to the user. Error and Alert helper text prefixes are localized and automatically displayed when the component’s [semanticState] is changed. | null |
| interactionSource | The [MutableInteractionSource] representing the stream of Interactions for this [NumberInputUiComponent]. You can create and pass in your own remembered [MutableInteractionSource] if you want to observe Interactions and customize the appearance / behavior of this [NumberInputUiComponent] in different Interactions. | remember { MutableInteractionSource() } |
| isDecimal | Boolean to control whether the number input will accept decimal values | true |
| isPercent | Boolean to control whether the number input will place a visual % sign at the end of the input | false |
| allowNegative | Boolean to control whether the numbuer input will accept negative inputs | true |
| maximumIntegerDigits | Maximum number of integer digits to show up before the decimal point | 100 |
| maximumDecimalDigits | Maximum number of decimal digits to show up after the decimal point | 100 |
| semanticState | Adjusts the state of the Component. This allows for enabling, disabling, warning, error, and required states. | SemanticState() |
Accessibility Guidelines
- Coming soon…
Content Guidelines
- Labels for Number Inputs are written in title case.
- Use helper text to instruct the user what the proper input may be.
- Use placeholder text only to provide examples of proper inputs. Never use placeholder text to help instruct users.
- For additional numeric content guidance review the Numbers section.
Can't Find What You Need?
Check out our FAQ section which may help you find the information you're looking for. For further information, contact the #ask-canvas-design or #ask-canvas-kitchannels on Slack.