Color
Typography
Spacing
Radius
Border
Opacity
Elevation
Blur
Avatar
Badge
Button
Checkbox
Input
ProgressBar
RadioButton
Separator
Slider
Switch
TextArea
TextLink
Accordion
Breadcrumb
ButtonGroup
Combobox
DropdownMenu
ListItem
Pagination
SegmentedControl
Select
Tooltip
Calendar
Card
CommandMenu
DatePicker
Dialog
Drawer
EmptyState
Footer
Form
NavigationBar
Sidebar
Skeleton
Table
Tabs
Toaster

Input

Single-line text field with a label, optional icons and helper text. Two sizes; Error shows the helper text as the error message.

Helper text

Size

Usage

Import the component and render it.

import { Input } from 'src/components/Input/Input';
import { LifebuoyIcon } from '@phosphor-icons/react';

<Input
  size="sm"
  label="Label"
  placeholder="Placeholder text"
  helperText="Helper text"
  iconStart={<LifebuoyIcon />}
  iconEnd={<LifebuoyIcon />}
/>

Accessibility

Role: textbox (native <input>).

KeyAction
TabMoves focus to the field (shows the Focus state)
TypingEdits the value; the Filled state applies once it is not empty
  • The Label is a <label for> the field: clicking it focuses the field. Without a label, pass aria-label.
  • The helper text is linked with aria-describedby; with error it is the error message and the field gets aria-invalid="true".
  • Icons are decorative (aria-hidden). For an action such as clearing the value, put a button with an aria-label in iconEnd.
  • Text inputs show :focus-visible on click as well as on Tab, so Focus appears whenever the field is being typed in.

Size

Set the size prop: Small is "sm", Medium is "md".

Helper text

Small

Helper text

Medium
<Input size="sm" />
<Input size="md" />

States

Disabled comes from the disabled prop; Error from the error prop; Filled from the content (defaultValue). Hover and Focus follow the pointer and the keyboard: try them in the playground.

Helper text

Default

Helper text

Disabled

Helper text

Error

Helper text

Filled
<Input disabled />
<Input error />
<Input defaultValue="Input text" />

Used in

Input is part of CommandMenu, DatePicker, Footer, Form and NavigationBar.

Actions

Pass callbacks to respond to the component.

import { Input } from 'src/components/Input/Input';
import { LifebuoyIcon } from '@phosphor-icons/react';

<Input
  size="sm"
  label="Label"
  placeholder="Placeholder text"
  helperText="Helper text"
  iconStart={<LifebuoyIcon />}
  iconEnd={<LifebuoyIcon />}
  onValueChange={(value) => console.log(value)}
/>
CallbackWhen
onValueChangeFires on every change.