Skip to content

Text field

Filled or outlined text input with a floating label, icons, affixes, counter, error icon and a text area.

import { TextField } from '@windmorph/react';

Purpose

Text fields let people enter and edit text. Reach for one for free-form input like a name, email or message; use a Select, RadioGroup or Checkbox when the choices are fixed.

Every field needs a name: pass a visible label or, when the context already makes the purpose clear, an aria-label / aria-labelledby (the types enforce one). The value is controlled through value / onChange(value) or left uncontrolled with defaultValue.

Do and don't

Do: Swap the supporting text for the error text, with errorMessage.
Don't: Don't add error text below the supporting text: the content under the field shifts.
Do: Keep the label short, clear and fully visible.
Don't: Don't write a label too long for the field: it gets cut off.

When not to use

For a yes/no choice use a Checkbox or Switch; for picking one of a few options use a Radio group.

See also

  • Text field on m3.material.io: Material's own guidelines, with anatomy and specs.
  • Checkbox: Selects any number of options, with checked, unchecked and indeterminate states.
  • Radio group: A set of radio buttons for picking exactly one option; a Radio needs a RadioGroup.
  • Slider: Chooses a value or a range on a continuous or stepped scale, in five sizes.