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
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add form-fieldOr install the full npm package:
npm install bigbulluiUsage
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 helperZero 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 />| Prop | Type | Description |
|---|---|---|
| label | React.ReactNode | Label content. |
| htmlFor | string | Id of the associated control. |
| description | React.ReactNode | Helper text. |
| error | React.ReactNode | Error message with shake-in animation. |
| required | boolean | Marks the field required. |
| className | string | Optional Tailwind or custom CSS classes merged with component styles. |
| children | React.ReactNode | Child elements rendered inside the component. |