apps/docs/content/docs/react/components/(forms)/input.mdx
import { Input } from '@heroui/react';
The Input component supports two visual variants:
primary (default) - Standard styling with shadow, suitable for most use casessecondary - Lower emphasis variant without shadow, suitable for use in Surface componentsWhen used inside a Surface component, use variant="secondary" to apply the lower emphasis variant suitable for surface backgrounds.
import {Input, Label} from '@heroui/react';
function CustomInput() {
return (
<div className="flex flex-col gap-2">
<Label htmlFor="custom-input">Project name</Label>
<Input
id="custom-input"
className="rounded-xl border border-border/70 bgsurface px-4 py-2 text-sm shadow-sm focus-visible:border-primary"
placeholder="New web app"
/>
</div>
);
}
The base class .input powers every instance. Override it once with @layer components.
@layer components {
.input {
@apply rounded-lg border border-border bgsurface px-4 py-2 text-sm shadow-sm transition-colors;
&:hover,
&[data-hovered="true"] {
@apply bg-surface-secondary border-border/80;
}
&:focus-visible,
&[data-focus-visible="true"] {
@apply border-primary ring-2 ring-primary/20;
}
&[data-invalid="true"] {
@apply border-danger bg-danger-50/10 text-danger;
}
}
}
.input – Native input element styling:hover or [data-hovered="true"]:focus-visible or [data-focus-visible="true"][data-invalid="true"] (also syncs with aria-invalid):disabled or [aria-disabled="true"][aria-readonly="true"]Input accepts all standard HTML <input> attributes plus the following:
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Tailwind classes merged with the component styles. |
type | string | "text" | Input type (text, email, password, number, etc.). |
value | string | - | Controlled value. |
defaultValue | string | - | Uncontrolled initial value. |
onChange | (event: React.ChangeEvent<HTMLInputElement>) => void | - | Change handler. |
placeholder | string | - | Placeholder text. |
disabled | boolean | false | Disables the input. |
readOnly | boolean | false | Makes the input read-only. |
required | boolean | false | Marks the input as required. |
name | string | - | Name for form submission. |
autoComplete | string | - | Autocomplete hint for the browser. |
maxLength | number | - | Maximum number of characters. |
minLength | number | - | Minimum number of characters. |
pattern | string | - | Regex pattern for validation. |
min | number | string | - | Minimum value (for number/date inputs). |
max | number | string | - | Maximum value (for number/date inputs). |
step | number | string | - | Stepping interval (for number inputs). |
fullWidth | boolean | false | Whether the input should take full width of its container |
variant | "primary" | "secondary" | "primary" | Visual variant of the component. primary is the default style with shadow. secondary is a lower emphasis variant without shadow, suitable for use in surfaces. |
For validation props like
isInvalid,isRequired, and error handling, use TextField with Input as a child component.