When to use
- Short free text: a name, an email address, a workspace URL.
- A value with a fixed prefix or unit beside it:
eased.dev/before a slug,EURafter an amount. - Any text control inside a Field, which gives it a label, help text and errors.
When not to use
- Text that runs to several lines: use a Textarea.
- Numbers people step up and down: use a Number Field.
- A fixed-length code from an SMS or an authenticator app: use an OTP Field.
- Picking from a known list: use a Select, or a Combobox when the list is long.
Installation
pnpm dlx shadcn add https://eased.dev/r/input.jsonnpx shadcn add https://eased.dev/r/input.jsonyarn dlx shadcn add https://eased.dev/r/input.jsonbunx --bun shadcn add https://eased.dev/r/input.jsonThe command adds Input, everything it builds on and Eased’s tokens to your project.
Install the dependencies
pnpm add @base-ui/reactnpm install @base-ui/reactyarn add @base-ui/reactbun add @base-ui/reactAdd the Eased pieces it builds on
Copy each item’s files the same way, or install them with the CLI:
Copy the source into your project
components/eased/input/input.tsxTSX "use client";import { Input as BaseInput } from "@base-ui/react/input";import type { ComponentProps, ReactNode } from "react";import { InputGroup, InputGroupAddon, controlClass, type ControlSize,} from "../_primitives/field/field";export type InputProps = Omit<ComponentProps<typeof BaseInput>, "size" | "className"> & { /** sm 32px, md 36px (default), lg 40px. */ size?: ControlSize; /** Leading content: an icon, or a prefix such as "https://". */ start?: ReactNode; /** Trailing content: a unit, a kbd hint, a button. */ end?: ReactNode; /** * Mark the input invalid outside a `Field` (inside one, the field's validity drives it): * red border, `aria-invalid`, and one shake when it turns on. */ invalid?: boolean; /** Classes for the bordered shell. */ className?: string; /** Classes for the `<input>` itself. */ controlClassName?: string;};/** * A text input on Base UI's Input, so it labels, describes and validates itself inside a * `Field`. Focus firms the border and grows a soft glow; an error shakes the box once, 6px, and the field's * message opens under it with a height spring. */export function Input({ size = "md", start, end, invalid, className = "", controlClassName = "", ...props}: InputProps) { return ( <InputGroup size={size} invalid={invalid} className={className}> {start !== undefined && <InputGroupAddon>{start}</InputGroupAddon>} <BaseInput {...props} {...(invalid !== undefined ? { "aria-invalid": invalid } : null)} className={`${controlClass} ${controlClassName}`} /> {end !== undefined && <InputGroupAddon>{end}</InputGroupAddon>} </InputGroup> );}Keep the folder layout
The files import each other by relative path (
../lib/motion), so keep each one at the path shown, undercomponents/eased/.
Usage
import { useState } from "react";import { Field } from "@/components/eased/field/field";import { Input } from "@/components/eased/input/input";export function WorkspaceUrl() { const [slug, setSlug] = useState("northwind"); return ( <Field label="URL" description="Changing it breaks links people have saved."> <Input value={slug} onValueChange={setSlug} start="eased.dev/" spellCheck={false} /> </Field> );}Examples
Standalone, with a unit
Outside a Field, name it with aria-label and drive the error state with invalid.
<Input aria-label="Amount" inputMode="decimal" end="EUR" invalid={amount > balance} />Validated as you type
Inside a Field, the field's validity drives the border and the shake; invalid is not needed.
<Field label="URL" validate={validateSlug} validationMode="onChange"> <Input value={slug} onValueChange={setSlug} start="eased.dev/" /></Field>API reference
Input
| Prop | Type | Default | Description |
|---|---|---|---|
size | "sm" | "md" | "lg" | "md" | 32, 36 or 40px tall. |
start | ReactNode | Leading content: an icon, or a prefix such as https://. | |
end | ReactNode | Trailing content: a unit, a kbd hint, a button. | |
invalid | boolean | Marks the input invalid outside a Field: danger border, aria-invalid, and one shake when it turns on. Inside a Field, the field's validity drives it. | |
className | string | "" | Classes for the bordered shell. |
controlClassName | string | "" | Classes for the <input> itself. |
Every other Base UI Input prop passes through to the <input>: value, defaultValue, onValueChange, type, placeholder, disabled, name, autoComplete and the rest.
Accessibility
- Inside a Field, Base UI ties the label to the input and points
aria-describedbyat the description and error. Outside one, passaria-label. invalidsetsaria-invalid, and the danger border stays while the input is focused, so the shake is never the only signal.- Pressing a non-interactive part of the shell, such as a prefix or an icon, focuses the input; buttons in an addon keep their own clicks.
- Text is 16px on touch screens so iOS does not zoom in on focus.
Motion
Hover steps the border up once; focus steps it up and grows a soft 3px glow, both over 200ms. An invalid input keeps its danger border and glows in danger while focused. When the input turns invalid the shell shakes once, 6px, over 360ms, and inside a Field the message line springs open under it. Reduced motion drops the shake and the colour transitions, so the border changes at once.
Notes for AI
Use Input for single-line text and wrap it in a Field for its label and messages. Put prefixes, units and icons in start and end rather than positioning them yourself, and use onValueChange for the string value.
Do not add your own focus ring, error border or shake: the shell draws them. Do not pass invalid inside a Field unless you mean to override the field's validity.
Related components
- Form Field with Validation: the label and message line around it.
- Auto-Resizing Textarea: for text that runs to several lines.
- Number Input with Steppers: for numbers with steppers.