Skip to main content

Components

Field

Field is a helper component to automatically associate a field with Label, Field.Description, ValidationMessage and Field.Counter.

Use Field when

  • you need to ensure that Label, Field.Description, ValidationMessage and Field.Counter are correctly associated with a field

Avoid Field when

  • you need to semantically group multiple fields; use Fieldset instead

Example

Prefix/Suffix

Prefixes and suffixes are useful for showing units, currency or other types of information relevant to the field. You should not use these on their own, as screen readers do not announce them. It is important that the same information shown in the prefix or suffix is also included in the label.

Character count

Use Field.Counter to inform users about the number of characters they can enter in the field.

Placement

When you use Field together with choice components such as Switch, you can place the label either before or after the control. This makes it easy to adapt the component to the context.

Guidelines

Field helps you structure form fields in an accessible and consistent way. It automatically links Label, Field.Description, ValidationMessage and Field.Counter to the relevant field using the correct ARIA attributes.

Edit this page on github.com (opens in a new tab)