robertlib

Form Error

Forms 1

About

A small validation message shown under a form field, that renders nothing when there is no error so it can be used unconditionally.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Form Error to your project and fits it to your theme.

Code

How Form Error is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import { useState } from "react";
import { Button } from "@/components/ui/button";
import FormError from "@/components/ui/form-error";

export default function Basic() {
  const [error, setError] = useState<string>();

  return (
    <div className="space-y-3">
      <Button
        onClick={() => setError(error ? undefined : "Something is missing.")}
        size="sm"
        variant="outline"
      >
        Toggle error
      </Button>
      {/* Renders nothing without children - no condition needed */}
      <FormError>{error}</FormError>
    </div>
  );
}

More by robertlib

View all
  • Timeline

    Timeline

    16
  • Chip

    Chip

    5
  • Switch

    Switch

    5
  • Spinner

    Spinner

    5
  • Progress Indicator

    Progress Indicator

    4
  • Collapsible Content

    Collapsible Content

    3
  • Empty State

    Empty State

    3
  • Checkbox

    Checkbox

    2

More in Forms

View all
  • Login 1

    Login 1

    64
  • Premium Auth

    Premium Auth

    571
  • Contact Card

    Contact Card

    1.1K
  • Form

    Form

    18
  • Book A Demo 1

    Book A Demo 1

    91
  • Authentication Card

    Authentication Card

    52
  • Card Studio

    Card Studio

    47
  • Login Card

    Login Card

    35