npx shadcn@4.23.1 add @goop/trail-field-errorField error
FreeThe error line under a form control whose value was refused, saying what to fix, inside the control's Field, for React and Tailwind CSS. Free, MIT.
What an agent sees
- FieldInvalidA control and, when its value is refused, the error line under it
import { FieldError, FieldInvalid } from '@/components/ui/goop/field-error';
import { Field } from '@/components/ui/goop/field';
import { TextInput } from '@/components/ui/goop/text-input';
<Field label="Work email">
<FieldInvalid error="Enter an address with an @ in it.">
<TextInput type="email" defaultValue="mira.example.com" />
</FieldInvalid>
</Field>Type an email without an @ and leave the field: the error arrives under it. Type a username and leave it: it is checked for a moment, and a taken one (fieldwork, admin, teodora) is refused. Change the words and the error goes. Look switches stacked fields, settings rows, rows with a description, rows with a region (open its list and close it with nothing chosen), or errors that run on to more lines. The username check is a timer over three names of our own.
When to use
- The error line under a form control whose value was refused, saying what to fix, inside the control's Field.
- Also called: validation message or error text.
Installation
Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Field error on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing.
npx shadcn@4.23.1 add @goop/trail-field-errorAdd the Goop Field error to this project. The install steps are at https://goop.so/docs/install.mdUsage
import { FieldError, FieldInvalid } from '@/components/ui/goop/field-error';
import { Field } from '@/components/ui/goop/field';
import { TextInput } from '@/components/ui/goop/text-input';
<Field label="Work email">
<FieldInvalid error="Enter an address with an @ in it.">
<TextInput type="email" defaultValue="mira.example.com" />
</FieldInvalid>
</Field>- Fits: account, flow (their recipes).
- width, gap, text: add no class for these.
API reference
- Types: FieldInvalidControlProps = { id?: string; 'aria-describedby'?: string; disabled?: boolean; 'aria-invalid'?: boolean | 'true' | 'false' }
| Part | What it is |
|---|---|
| FieldInvalid | A control and, when its value is refused, the error line under it; error?: ReactNode — What is wrong and how to put it right; nothing, false or '' shows no error; errorId?: string — The error line's id; a generated one when left out; id?: string — The control's id, handed on to it (never the group's); aria-describedby?: string — What else describes the control, handed on to it before the error's id; disabled?: boolean — Disables the control (never the group) and dims the error line with it; children: ReactElement<FieldInvalidControlProps> | ((control: FieldInvalidControlProps) => ReactNode) — The control, or a function that spreads the wiring on a nested control |
- data-slot values (to select a part by): field-error, field-error-group, field-error-icon, field-error-text
Accessibility
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| disabled | the attribute data-disabled |
Notes for AI
Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.