Field
Label, hint, error and required marker, wired to whatever control is inside it.
- Category
- Forms
- Access
- Free with an account
- Source
- 134 lines · one file
- Added
- 4 Oct 2026
The decision inside it
Errors replace hints, they do not stack
A field with a hint and an error under it reads as two messages. When there is an error, it takes the hint's place and the description points at it.
When to use it
Use Field to wrap any form control with its label, hint, error and optional or required marker, wired for screen readers. Put an Input, Textarea, Select or Switch inside.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Liro's Field for this.
Install it: npx shadcn@latest add @liro/field
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/field.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Free components install through the @liro registry with your CLI token: see the Namespaced tab.
Usage
import { Field } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
export function EmailField({ error }: { error?: string }) {
return (
<Field label="Work email" hint="We send receipts here." error={error} required>
<Input type="email" name="email" placeholder="you@company.com" />
</Field>
);
}API reference
“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Type | Notes | ||
|---|---|---|---|
label | React.ReactNode | Yes | – |
hint | React.ReactNode | No | One line under the control. Replaced by `error` when there is one. |
error | React.ReactNode | No | Marks the control invalid and is announced with it. |
optional | boolean | No | Adds "Optional" beside the label; the rarer case gets the mark. |
required | boolean | No | – |
inline | boolean | No | Put the label beside the control instead of above — for checkboxes and switches. |
children | React.ReactNode | Yes | – |
Dependencies
npm packages
@radix-ui/react-labelclsxtailwind-mergeLiro foundations, installed alongside it
liro-themeAccessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances