Ashish Sharma

Field

Forms

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>
  );
}

Dependencies

More by Ashish Sharma

View all
  • Perspective Gallery

    Perspective Gallery

    149
  • Bento Features

    Bento Features

    27
  • Animated Sidebar

    Animated Sidebar

    25
  • Otp Input

    Otp Input

    25
  • Glow Ring

    Glow Ring

    20
  • Notification Stack

    Notification Stack

    11
  • Expandable Tabs

    Expandable Tabs

    11
  • Voice Orb

    Voice Orb

    8

More in Forms

View all
  • Form

    Form

    7
  • Login 2

    Login 2

    16
  • Contact Form

    Contact Form

    32
  • Book A Demo 1

    Book A Demo 1

    95
  • Contact Card

    Contact Card

    1.1K
  • Premium Auth

    Premium Auth

    613
  • Authentication Card

    Authentication Card

    52
  • Form

    Form

    18