npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-field-error.json --yesField error
ProThe error line under a form control whose value was refused, saying what to fix, inside the control's Field, for React and Tailwind CSS. Part of Goop Pro.
What an agent sees
- FieldInvalidA control and, when its value is refused, the error line under it
import { useState } from 'react';
import { Field } from '@/components/ui/goop/field';
import { FieldError, FieldInvalid } from '@/components/ui/goop/field-error';
import { TextInput } from '@/components/ui/goop/text-input';
function WorkEmail({ refused }: { refused?: string }) {
const [email, setEmail] = useState('sam.rivera@');
const error = /@[^@\s]+\.[^@\s]+$/.test(email) ? undefined : 'Enter a full address.';
return (
<div className="flex w-80 flex-col gap-3">
<Field label="Work email" orientation="vertical" className="w-full">
<FieldInvalid error={error}>
<TextInput type="email" value={email} onChange={(event) => setEmail(event.target.value)} />
</FieldInvalid>
</Field>
{refused ? <FieldError role="alert">{refused}</FieldError> : null}
</div>
);
}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. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-field-error.json --yesAdd the Goop Field error to this project. The install steps are at https://goop.so/docs/install.mdUsage
import { useState } from 'react';
import { Field } from '@/components/ui/goop/field';
import { FieldError, FieldInvalid } from '@/components/ui/goop/field-error';
import { TextInput } from '@/components/ui/goop/text-input';
function WorkEmail({ refused }: { refused?: string }) {
const [email, setEmail] = useState('sam.rivera@');
const error = /@[^@\s]+\.[^@\s]+$/.test(email) ? undefined : 'Enter a full address.';
return (
<div className="flex w-80 flex-col gap-3">
<Field label="Work email" orientation="vertical" className="w-full">
<FieldInvalid error={error}>
<TextInput type="email" value={email} onChange={(event) => setEmail(event.target.value)} />
</FieldInvalid>
</Field>
{refused ? <FieldError role="alert">{refused}</FieldError> : null}
</div>
);
}- Fits: account, flow (their recipes).
- height, 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 — The sentence that says what is wrong and how to put it right; nothing, false or '' shows no error; errorId?: string — The error line's id, where the caller needs its own; a generated one otherwise; id?: string — The control's id, handed on to it (never the group's): the id a field holding the group points its label at; aria-describedby?: string — What else describes the control (a field's description), handed on to it before the error's id; disabled?: boolean — Disables the control (never the group) and dims the error line with it: a disabled field hands it on; 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 prop 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.