Componentform0.88 KB gzipZero dependencies

Form Field

Field wrapper with label, control, description, and error message with a shake-in animation on error.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add form-field

Or install the full npm package:

npm install bigbullui

Usage

tsx5 lines
import { FormField } from "@/components/ui/form-field"; <FormField label="Email" htmlFor="email" description="We never share it." error={error} required>  <input id="email" /></FormField>

Source code

form-field.tsx + 1 helper

Zero third-party dependencies (2 local files shown in tabs below).

tsxform-field.tsx95 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export type FormFieldProps = Omit<React.HTMLAttributes<HTMLDivElement>, "title"> & {  label?: React.ReactNode;  htmlFor?: string;  description?: React.ReactNode;  error?: React.ReactNode;  required?: boolean;  className?: string;  children?: React.ReactNode;}; export const FormField = React.forwardRef<HTMLDivElement, FormFieldProps>(function FormField(  { label, htmlFor, description, error, required = false, className, children, ...props },  ref,

Props

Interactive Prop Playground

Tweak parsed AST props below to generate ready-to-paste JSX.

tsx3 lines
import { FormField } from "@/components/ui/form-field"; <FormField />
PropTypeDescription
labelReact.ReactNodeLabel content.
htmlForstringId of the associated control.
descriptionReact.ReactNodeHelper text.
errorReact.ReactNodeError message with shake-in animation.
requiredbooleanMarks the field required.
classNamestringOptional Tailwind or custom CSS classes merged with component styles.
childrenReact.ReactNodeChild elements rendered inside the component.