Skip to content

Field

Stable

Wraps any form control with a visible label, hint text and an error message, and wires them together.

Also known as form field, form control, form item, label and help text

Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.

With a hint and an error

Shown in the sidebar.

Type one or two letters to see the error appear. The message has an icon and words, not only colour.

When to use it

Gives a control a visible name and the help and error text it needs, linked the way assistive technology expects, so each form field is built the same way.

Made of: Label · Required mark or (optional) · Control · Hint · Error with icon

Use it for

  • A text, number or select control in a form or settings panel.
  • A field that needs help text before the user types.
  • A field that shows a message when the value is not accepted.

Not for

  • An on-off setting with its label beside it: use Switch.
  • A choice between a few options shown side by side: use SegmentedControl.
  • The message box in a chat: use Composer.

Do and avoid

We send the invoice here.

Do. A label that stays put, with help text underneath.
Avoid. The hint inside the box disappears as soon as people type.

Do

  • Spread everything the function gives you onto the control.
  • Keep the label short and always visible.
  • Use hint for rules the user needs before typing, such as a length or format.
  • Show the error after the user has left the field or tried to submit.

Avoid

  • Do not use a placeholder in place of a label. It disappears when typing starts.
  • Do not show an error with colour only. Field always adds an icon and text.
  • Do not wrap a Switch in a Field. Put its label beside it.
  • Do not write your own id and htmlFor pair. Field makes them for you.

On a phone

  • Label, control, hint and error stack in one column at the full width of the container.
  • The control inside it follows its own phone rules: 44px tall and 16px text on touch screens.
  • The error area is always on the page and is announced without moving focus, so the user is not pulled out of the field.

Build your next AI screen with Tattva.

Free and open, with the code. Start in one line.

Get started