npx shadcn@4.23.1 add @goop/meadow-text-inputText input
FreeA single-line field for free words, such as a task's title, a name or an email, for React and Tailwind CSS. Free, MIT.
What an agent sees
import { useState } from 'react';
import { TextInput } from '@/components/ui/goop/text-input';
function NewTaskField({ onAdd }: { onAdd: (title: string) => void }) {
const [title, setTitle] = useState('');
return (
<form
onSubmit={(event) => {
event.preventDefault();
if (title.trim()) onAdd(title.trim());
setTitle('');
}}
>
<TextInput
aria-label="New task"
placeholder="Add a field task"
value={title}
onChange={(event) => setTitle(event.target.value)}
/>
</form>
);
}
function SiteCodeField({ code, error }: { code: string; error?: string }) {
return (
<TextInput aria-label="Site code" defaultValue={code} aria-invalid={error ? true : undefined} />
);
}
function SubjectLine() {
return <TextInput variant="bare" aria-label="Subject" placeholder="Subject" />;
}
function CrewSizeField() {
return <TextInput size="sm" aria-label="Crew size" placeholder="How many on the crew" />;
}Type in it; switch every look and type (the time box is always a time), disabled, invalid and read-only. Nothing is sent; the search bar's own field is tried on the search bar's page.
When to use
- A single-line field for free words, such as a task's title, a name or an email.
- Also called: text field.
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 Text input 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/meadow-text-inputAdd the Goop Text input to this project. The install steps are at https://goop.so/docs/install.mdUsage
import { useState } from 'react';
import { TextInput } from '@/components/ui/goop/text-input';
function NewTaskField({ onAdd }: { onAdd: (title: string) => void }) {
const [title, setTitle] = useState('');
return (
<form
onSubmit={(event) => {
event.preventDefault();
if (title.trim()) onAdd(title.trim());
setTitle('');
}}
>
<TextInput
aria-label="New task"
placeholder="Add a field task"
value={title}
onChange={(event) => setTitle(event.target.value)}
/>
</form>
);
}
function SiteCodeField({ code, error }: { code: string; error?: string }) {
return (
<TextInput aria-label="Site code" defaultValue={code} aria-invalid={error ? true : undefined} />
);
}
function SubjectLine() {
return <TextInput variant="bare" aria-label="Subject" placeholder="Subject" />;
}
function CrewSizeField() {
return <TextInput size="sm" aria-label="Crew size" placeholder="How many on the crew" />;
}- Fits: account, settings (their recipes).
- Also known as: Input.
- Its look is its own: a
classNameplaces it (width, margin, flex or grid place), never restyles it. A key hint or an action beside the field is the caller's, in a wrapper element round it. - height, width, padding, corner, border, background, text, motion: add no class for these.
API reference
| Option | Type | What it does |
|---|---|---|
| variant | filled | bare | default | unstyled | ghost | title | heading | heading-sm | search | search-outline | search-raised | time = filled | |
| size | sm | md | lg = md | |
| type? | 'text' | 'email' | 'password' | 'search' | 'tel' | 'url' | The input's own type; left out, text (search on the two framed search looks); variant="time" forces time. |
| value? | string | |
| defaultValue? | string | |
| onChange? | (event: ChangeEvent<HTMLInputElement>) => void | |
| name? | string | |
| required? | boolean | |
| disabled? | boolean | |
| form? | string |
- Class recipes (cva): textInputVariants (TextInput)
- data-slot values (to select a part by): text-input
Accessibility
- The native element answers the keyboard.
- hover, focus: the browser's own (:hover, :focus): write nothing
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| focus-visible | the attribute data-focus-visible |
| disabled | the prop disabled |
| invalid | the attribute aria-invalid |
Motion
- The part sets its own motion: add no transition or animation of your own.
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.