robertlib

Form Error

Forms

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

    13
  • Spinner

    Spinner

    5
  • Switch

    Switch

    4
  • Collapsible Content

    Collapsible Content

    3
  • Chip

    Chip

    2
  • Empty State

    Empty State

    2
  • Checkbox

    Checkbox

    1
  • Progress Indicator

    Progress Indicator

    1

More in Forms

View all
  • Authentication Card

    Authentication Card

    51
  • Contact Card

    Contact Card

    1.1K
  • Premium Auth

    Premium Auth

    560
  • Book A Demo 1

    Book A Demo 1

    88
  • Modern & Stunning sign in

    Modern & Stunning sign in

    1.7K
  • Card Studio

    Card Studio

    46
  • SignInPage

    SignInPage

    741
  • Form

    Form

    139