components / Actions and Inputs

Input

Input can have a placeholder, a default (initial) value, a label and a description. Label can be required or optional as well.

States

Input can provide a visual representations of its status with disabled, error, readonly and loading states. You can use any combination of those states for the experience.

Default

Disabled

Error

Readonly

Loading

Label, Counter, and Placeholder

Labels should be used to describe the information we're asking the user to give us. Placeholders should be used to show an example of the content we're asking the user for. If we use placeholders as labels, once the user starts typing into the field, they lose the description of what we're asking for.

Label Help

Labels can have a help icon with a tooltip to provide additional context to a label.

Required and Optional

A visual indicator can be applied on a Input's label.

Counter

Counter can be displayed when there is a maxLength.


Action

Input action can be used to combine a text input with an action button, making them visually merged into a single block.

Addons

Input addons can be used to show an icon or a text that help users enter information in the Input. These serve as decorative additions, not additional actions.

Addon Guidance

Addons are helpful when they enhance the understanding of an input. This can be particularly useful with units of measurement, where fields may have specific formats, and with icons that are universally understood.

Addons should be avoided when they don't serve a use for users or when the addon's meaning is not well understood. A good default is to design without an addon, and only adding one to further enhance its usability.

Sizes

Inputs can appear in three different sizes. The medium size is the default size, while small and large will allow the inputs to resize to take up more and less space in a layout. These match up with our Button sizes.

Focus

An input can be focused via a ref


Best Practices

Inputs should:

  • Be clearly labeled so it’s obvious to the user what they should enter into the field
  • Only ask for information that’s really needed
  • Validate input as soon as merchant has finished interacting with a field (but not before)

Content Guidelines

Use a label for all input fields

A label is a short, meaningful description that clearly indicates what the user is expected to enter. Labels should be 1 to 3 words and written in title case. Labels should primarily be nouns. Avoid using labels as CTAs. A label is not inline help and shouldn’t be used to provide instruction.


Follow capitalization rules

Input labels should be written in title case.


Avoid using placeholder text

Placeholder text has several accessibility issues:

  • Text has low contrast which makes the text hard to read
  • Text disappears as soon as the user starts typing
  • Can’t accommodate additional context due to limited space
  • Unreliable for screen readers

Use inline help to provide hints, formatting, and requirements.

Placeholders in Form Fields Are Harmful (Nielsen Norman Group)


Show hints, formatting, and requirements

Inline help should explain a feature or the outcome of the actions the user is about to take.

The description should adapt to the situation and context. The guidance could be focused on what is needed, or it could describe how to enter it.

  • An overall description of the input field
  • Hints for what kind of information needs to be input
  • Specific formatting examples or requirements

Do not repeat the label in order to prompt someone to interact with it.

Don’t add inline help when unneeded or solely to make it match other inputs that have inline help text.

Use sentence case, and only include period if more than one sentence is used.

Follow the inline help content guidelines.

Format: HH:MM AM
Enter a time

Keep overlay help short, simple, and scannable

Overlay help should be short and easily scannable, no longer than a single phrase or short sentence.

Avoid repeating the UI text. Use sentence case, and only include period if more than one sentence is used.

For more complex or important information, consider another method of presentation, e.g., inline help or a link to the knowledge base.


Components

  • To build a full form, use the Form component.
  • For multiline text input, use a TextArea.

Patterns

  • Form design pattern for how related controls are ordered.

Importing

import { Input } from '@servicetitan/design-system';