Skip to Content
Getting startedFoundationsComponentsPackagesTools

Input

A text field with its label, hint and error.

Examples

Playground

States

Every state side by side. Hover and focus are forced, so they can be reviewed without a pointer.

rest
hover
focus
filled
error
That address is not valid.
disabled

Content

A hint, the required mark, adornments, and a value longer than the field.

hint
We only use it to sign you in.
required
prefix and suffix
£.00
long value

In context

A form row: an Input, a Select and an md Button share one height, label style and corner.

Install

npx shadcn add @hipuku/input

Usage

import { Input } from '@/components/haus/components/Input'

<Input label="Email" type="email" hint="We never share it." value={email} onChange={e => setEmail(e.target.value)} />

API

Input also takes the input's own attributes and forwards its ref to the input. className lands on the root and controlClassName on the field's box.

PropTypeDescription
labelstring
hintstring
errorstring
prefixReact.ReactNode
suffixReact.ReactNode
requiredboolean
controlClassNamestringLands on the field itself rather than the root, for the cases where the control needs styling and the block around it does not. Ruling B5 put className on the root of every component; this is the named second target that rule asks for rather than redirecting the one everyone expects.

States

hint is a line of help under the field. error marks it invalid and shows above the hint, which stays, because it is what the user needs to fix the field. prefix and suffix hold a unit or a symbol inside the field. An Input stands level with a default Button beside it.

required marks the field and sets aria-required, not the browser's own required, so the browser shows no validation bubble of its own. Show the problem with error.

Accessibility

  • A native input with a real label: clicking the label focuses the field.
  • The hint and error are read as the field's description. An error is announced when it appears.
  • error sets aria-invalid, and is not shown by colour alone.

On this page