Home

Input

UsageDevelopment

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:

  1. Border
  2. Label
  3. Leading slot (optional)
  4. Trailing slot (optional)
  5. Help icon (optional)
  6. Hint text (optional)
  7. Placeholder text (optional)
  8. Indicator (optional)

Anatomy of the input component.

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:

  1. The Input is still empty while users try to submit;

Input in error status.

  1. The data entered in the Input doesn’t meet the validation rules.

Input with validation error message.

Success

An Input can also receive an success status when the input is successfully validated.

Input in success status.

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 numberDateVerification codePassword

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.

Phone number with visible placeholder values.

Phone number is filled out.

Invalid phone number with Enter a phone number error.

Invalid phone number with Enter a valid phone number.

Phone number in a valid state.

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.

Date input with visible placeholder.

Invalid date input with Enter a date of birth error.

Invalid date input with Enter a full date of birth error.

Date input in a valid state.

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 input with visible placeholder.

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.

Empty verification code input.

Invalid verification code input with Enter the verification code error.

Invalid verification code input with Enter the full verification code error.

Verification code input in a valid state.

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.

Password input with visible placeholder.

Invalid password input with Enter your password error.

Invalid password input with This password doesn’t meet the requirements error.

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.

LanguageExampleDelimitersOrder
British English23/04/2025/ (slash)DD/MM/YYYY
Dutch23-04-2025- (dash)DD-MM-YYYY
German23.04.2025. (dot)DD.MM.YYYY
Danish23-04-2025- (dash)DD-MM-YYYY
Finnish23.4.2025. (dot)DD.M.YYYY
Norwegian23.04.2025. (dot)DD.MM.YYYY
Swedish2025-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.

LanguageExampleThousand separatorDecimal separatorSymbol position
British English€1,234.56,.Before, no space
Dutch€ 1.234,56.,Before, space
German1.234,56 €.,After, space
Danish1.234,56 €.,After, space
Finnish1 234,56 €Space,After, space
Norwegian1 234,56 €Space,After, space
Swedish1 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.

Input with euro sign in placeholder.

Input with euro sign in placeholder.

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.

LanguageExampleDecimal separatorSymbol position
British English12.34%.After, no space
Dutch12,34 %,After, space
German12,34 %,After, space
Danish12,34 %,After, space
Finnish12,34 %,After, space
Norwegian12,34 %,After, space
Swedish12,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.

Input with percentage sign in leading slot.

Input without percentage sign in leading slot.

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

ComponentEventDescriptionDetails
<r-input />rInputEmitted immediately after components value change.
  • element: HTMLRInputElement
  • value: any
rChangeEmitted if components value changes after element loses focus.
rResetOccurs when a form is reset (resets component’s value to initial).
rClickIconEmitted when click on the icon within input occurs.
rValidateEmitted 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

  1. Apply validity-related type if necessary: type="email", type="number", etc.
  2. 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 and maxlength: Specifies the minimum and maximum length of textual data (strings).
  • min and max: Specifies the minimum and maximum values of numerical input types.
  • type: Specifies whether the data needs to be a number, an email address, or some other specific preset type.
  • pattern: Specifies a regular expression that defines a pattern 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:

  1. novalidate attribute passed to the form:
    <form novalidate ...>;
  2. 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

  1. indicating invalid state by passing invalid prop
  2. 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:

  1. valid as an indication that value of the field passes validation;
  2. valid-marker as allowance for visual indication to be shown;
<r-input
  type="text"
  value="An example"
  valid
  valid-marker
/>