Skip to content
Browse docs and components

Input

input

A text field with a real label, optional description, an error that is announced and wired up with aria-describedby, and room for an icon on either side. Sizes and the invalid state come from the same tokens as every other Forme surface.

Responsive

Install

$npxshadcnadd@forme/input

Adds the component, its registry dependencies, and the token stylesheet you import once.

Usage

import { Input } from "@/components/forme/input/input";

<Input label="Email" type="email" description="We send the receipt here." />

When to use

Reach for it

  • A single line of text, with its label, its help text and its error in one component.

Use something else

  • Several lines of text; use a Textarea.
  • A one-time code split into boxes; that is the OtpInput.

API reference

Read from the source, so it is the API of the file you install. A prop marked * is required.

Input

PropTypeDefaultDescription
label*string—Visible label. Required rather than optional: an unlabelled field is a mystery to anyone using a screen reader, and a placeholder is not a label.
descriptionReactNode—Help text under the field. Replaced by error when there is one.
errorstring—Marks the field invalid and is announced as soon as it appears.
leadingReactNode—Sits inside the field before the text. Decorative and unclickable, so it is hidden from assistive technology; use trailing for anything a person has to reach.
trailingReactNode—Sits inside the field after the text. Buttons are allowed.
size'md' | 'lg'"md"

Also takes every prop of <input> attributes.

Accessibility

  • label is required, and the help text and error are tied to the field with aria-describedby.
  • An error sets aria-invalid and is announced as an alert.