About
A form field wrapper that pairs a label, hint, error and optional async status with its control, wired with matching aria attributes for assistive tech.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Field to your project and fits it to your theme.
Code
How Field is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
import * as React from "react";
import { Field } from "@/components/ui/field";
export default function FieldDemo() {
const [email, setEmail] = React.useState("");
const touched = email.length > 0;
const valid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email.trim());
const error = touched && !valid ? "Enter a valid email address." : undefined;
return (
<div className="w-full max-w-sm">
<Field
label="Email"
description="We'll send a confirmation link to this address."
error={error}
required
>
{(controls) => (
<input
{...controls}
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="you@example.com"
className="h-10 w-full rounded-md border border-border bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring"
/>
)}
</Field>
</div>
);
}
















