Skip to content

Input

A single line of text: plain, email, password, search and the like.

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

Examples

Types

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

export default function InputTypes() {
  return (
    <div className="grid gap-4 sm:grid-cols-2">
      <Field label="Text">
        <Input placeholder="Placeholder" />
      </Field>
      <Field label="Email">
        <Input type="email" placeholder="name@example.com" />
      </Field>
      <Field label="Search">
        <Input type="search" />
      </Field>
      <Field label="Read only">
        <Input readOnly value="demo@example.com" />
      </Field>
    </div>
  );
}

How it works

  • Inside a Field it picks up the field’s id, aria-invalid and aria-describedby. A prop you set yourself wins.
  • It also works on its own. Then give it a name for screen readers, such as aria-label.
  • The text box itself is the native input with the system’s styles, so typing, autofill and phone keyboards work as usual.
  • For other kinds use Select, DatePicker, NumberInput or Checkbox.

Props

Every input attribute, including ref, is passed through.

Input props
PropTypeDefaultDescription
classNamestring—Extra classes, for spacing or width. Utility classes override the component’s own styles.

Tokens

Tokens
TokenDefaultSets
--field-radius--radius-controlCorner radius
--field-background--surfaceFill
--field-border--borderBorder colour. An invalid control uses --critical.
--field-padding-x0.75remSide padding
--field-padding-y0.5remTop and bottom padding
--field-font-size0.875remText size of the field and its control