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
Fieldit picks up the field’sid,aria-invalidandaria-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,NumberInputorCheckbox.
Props
Every input attribute, including ref, is passed through.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Extra classes, for spacing or width. Utility classes override the component’s own styles. |
Tokens
| Token | Default | Sets |
|---|---|---|
--field-radius | --radius-control | Corner radius |
--field-background | --surface | Fill |
--field-border | --border | Border colour. An invalid control uses --critical. |
--field-padding-x | 0.75rem | Side padding |
--field-padding-y | 0.5rem | Top and bottom padding |
--field-font-size | 0.875rem | Text size of the field and its control |