Input
About
An Input allows users to enter short texts or data, such as names, email addresses, amounts, and dates.
Anatomy
A default Input consists the following mandatory and optional elements:
- Border
- Label
- Leading slot (optional)
- Trailing slot (optional)
- Help icon (optional)
- Hint text (optional)
- Placeholder text (optional)
- Indicator (optional)
In a default Input nothing is predefined. It can, amongst other things, be used to create inputs for:
- Name input
- Email addresses
- URLs
- Credit card numbers
- IBAN numbers
- Etc.
When to use
Use an Input when:
- You want to allow users to enter text or data themselves;
- And the text or data users will enter is not something that can be defined in a set of options to select from.
When not to use
Do not use an Input when:
- The text or data users will enter, can be defined in a set of options to select from. Instead, use the Select component for that;
- You want to allow users to do a global or contextual search. Instead, use a Search component for that (coming soon).
Statuses
Error
An Input can receive an error status because of two reasons:- The Input is still empty while users try to submit;
- The data entered in the Input doesn’t meet the validation rules.
Success
An Input can also receive an success status when the input is successfully validated.Keyboard behaviour
Tab
- Moves focus to the Icon button (help icon) if showcased first;
- Then moves to the input.
- Proceeds to next interactive element, such as another input or to a submit button.
Arrow left/right
- Moves cursor within the text.
Accessibility
Aria label
Make sure that the Icon buttons you use in your design come with a clear Aria label. Read the Icon button guidelines.Variants
Phone number
A phone number input can be used for allowing users to enter a phone number. A placeholder text might support users to understand the needed input, as well as a hint text or popover. The select field allows users to select their country code.
The default placeholder icon for the country selector is a globe, indicating international dialing codes. This visual cue helps users understand they can select their country/region before entering the phone number.
Validation rules often apply and need to be defined and implemented by product teams themselves.
Date input
A date input can be used for allowing users to enter a date. For example, a date of birth. This variant has by default a Placeholder text, so users know what date format is required. A hint text and popover might be used to provide additional explanation.
In case users will be able to select a date from a calendar component, a calendar in form of an Icon button should be shown in the trailing slot. Currently, Riverty Design System does not offer a calendar component.
Date formats
For the date formats per language, you can look at the Content guidelines at the end of this page. In case another format is needed, this can be adjusted manually (e.g., MM/YY for expiration date of creditcard).Validation rules often apply and need to be defined and implemented by product teams themselves.
Verification code
A verification code input allows users to enter a code consisting of digits, letters or a combination of both. Currently, the code can exist from 4 digits up to 10 characters. By default a placeholder is used indicating the number of characters needed. A hint text and popover might be used to provide additional explanation.
Validation rules often apply and need to be defined and implemented by product teams themselves.
Password input
A password input can be used for allowing users to enter a password. It has two extra modes; unfilled and filled. By default, it’s better to not use a placeholder text. A hint text and popover might be used to provide additional explanation.
A Password input does not have a validation status. In case users create a new password, a validation box can be shown below the Password input. Riverty Design System doesn’t offer this element, yet.
Formatting
Date formats
Date formats differ per language. In Figma, you will see the English format being used as a default. In code, date formats for the following languages are built into the Input component.Language | Example | Delimiters | Order |
---|---|---|---|
British English | 23/04/2025 | / (slash) | DD/MM/YYYY |
Dutch | 23-04-2025 | - (dash) | DD-MM-YYYY |
German | 23.04.2025 | . (dot) | DD.MM.YYYY |
Danish | 23-04-2025 | - (dash) | DD-MM-YYYY |
Finnish | 23.4.2025 | . (dot) | DD.M.YYYY |
Norwegian | 23.04.2025 | . (dot) | DD.MM.YYYY |
Swedish | 2025-04-23 | - (dash) | YYYY-MM-DD |
Amount formats
Amount formats differ per language as well. In Figma, you will see the English format being used as a default. In code, amount formats for the following languages are built into the Input component.Language | Example | Thousand separator | Decimal separator | Symbol position |
---|---|---|---|---|
British English | €1,234.56 | , | . | Before, no space |
Dutch | € 1.234,56 | . | , | Before, space |
German | 1.234,56 € | . | , | After, space |
Danish | 1.234,56 € | . | , | After, space |
Finnish | 1 234,56 € | Space | , | After, space |
Norwegian | 1 234,56 € | Space | , | After, space |
Swedish | 1 234,56 € | Space | , | After, space |
A euro sign is automatically added as placeholder text to show users the required input. Depending on the language, in case an amount is entered the euro sign may change position.
Percentage formats
Percentage formats differ per language as well. In Figma, you will see the English format being used as a default. In code, percentage formats for the following languages are built into the Input component.Language | Example | Decimal separator | Symbol position |
---|---|---|---|
British English | 12.34% | . | After, no space |
Dutch | 12,34 % | , | After, space |
German | 12,34 % | , | After, space |
Danish | 12,34 % | , | After, space |
Finnish | 12,34 % | , | After, space |
Norwegian | 12,34 % | , | After, space |
Swedish | 12,34 % | , | After, space |
A percentage sign is automatically added as placeholder text to show users the required input. Depending on the language, in case data is entered the percentage sign will be shown after with or without a space.
Content
Please visit the Forms pattern to read documentation about:
- How to write labels for form components;
- When to use and how to write hint texts for form components;
- When to use and how to write placeholder texts for form components;
- How to deal with the Required and Optional additional labels in form components;
- When to make use of an info icon button in form components to trigger a Popover.
Leading vs. trailing icons
In general, the rule of thumb is that leading icons are supporting icons and therefore consist of an Icon component, and trailing icons are interactive icons and therefore consist of an Icon button component.Nesting components
An Input component can use:
- Icon component
- Icon button component
An Input component can be used in:
- Forms pattern
- Dialog component
Resources
Events
Component | Event | Description | Details |
---|---|---|---|
<r-input /> | rInput | Emitted immediately after components value change. |
|
rChange | Emitted if components value changes after element loses focus. | ||
rReset | Occurs when a form is reset (resets component’s value to initial). | ||
rClickIcon | Emitted when click on the icon within input occurs. | — | |
rValidate | Emitted after validation of element with Constraint Validation API. | — |
Validation API
By default r-input
validation is on and uses Constraint Validation API. It’s a default way modern browsers provide to deal with data validation without creating any validation function aside.
Using built-in form validation requires usage of attributes supported by validation engine.
How to apply
- Apply validity-related type if necessary:
type="email"
,type="number"
, etc. - Apply validity-related attributes:
required
,maxlength
,minlength
,max
,min
,pattern
,step
.
As described by mdn:
required
: Specifies whether a form field needs to be filled in before the form can be submitted.minlength
andmaxlength
: Specifies the minimum and maximum length of textual data (strings).min
andmax
: Specifies the minimum and maximum values of numerical input types.type
: Specifies whether the data needs to be anumber
, anemail
address, or some other specific preset type.pattern
: Specifies a regular expression that defines apattern
the entered data needs to follow.
There are two things Riverty components provide on top of existing API:
- unified visual appearance according to Riverty Design System;
- an ability to pass custom messages (per state) for any invalid state;
Validation messages
Validation messages will be displayed according to ValidityState:
- badInput
- patternMismatch
- rangeOverflow
- rangeUnderflow
- stepMismatch
- tooLong
- tooShort
- typeMismatch
- valueMissing
Custom validation message could be displayed by providing prop named as a combination of ValidityState name and a word message:
<r-input
type="text"
required
value-missing-message="Value is missing."
/>
Switch validation off
To stop application of Constraint Validation API one of two options must be applied:
novalidate
attribute passed to the form:<form novalidate ...>
;formnovalidate
property passed to submitting image, input or button:<input type="submit" formnovalidate ...>
Visual validation indication
There is a way to visually indicate validity states and provide validity-related messages without Constraint Validation API being used.
By adding invalid
prop invalid state indication will be provided.
<r-input
type="text"
value="An example"
invalid
/>
Text of an error message provided could be provided by
- indicating invalid state by passing
invalid
prop - passing text of the message as text value to
error
prop.
<r-input
type="text"
value="An example"
invalid
error="Description of an error"
/>
To indicate valid state visually two boolean props must be provided:
valid
as an indication that value of the field passes validation;valid-marker
as allowance for visual indication to be shown;
<r-input
type="text"
value="An example"
valid
valid-marker
/>