Componentform0.91 KB gzipZero dependencies

Field

Composable field primitives: Field, FieldLabel, FieldControl, FieldDescription, FieldError, FieldGroup, FieldSet.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

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

npx bigbullui add field

Or install the full npm package:

npm install bigbullui

Usage

tsx8 lines
import { Field, FieldLabel, FieldControl, FieldDescription, FieldError } from "@/components/ui/field"; <Field>  <FieldLabel htmlFor="name" required>Name</FieldLabel>  <FieldControl><input id="name" /></FieldControl>  <FieldDescription>Your full name.</FieldDescription>  <FieldError>Please enter a name.</FieldError></Field>

Source code

field.tsx + 1 helper

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

tsxfield.tsx157 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export type FieldErrorProps = React.HTMLAttributes<HTMLParagraphElement> & {  children?: React.ReactNode;}; export type FieldGroupProps = React.HTMLAttributes<HTMLDivElement> & {  children?: React.ReactNode;}; export type FieldSetProps = React.FieldsetHTMLAttributes<HTMLFieldSetElement> & {  legend?: React.ReactNode;  children?: React.ReactNode;}; 

Props

Interactive Prop Playground

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

tsx3 lines
import { FieldLabel } from "@/components/ui/field"; <FieldLabel />
PropTypeDescription
fieldClassNamestringConfigures field class name.
labelReact.ReactNodeLabel content.
htmlForstringConfigures html for.
descriptionReact.ReactNodeHelper text.
errorReact.ReactNodeError message.
requiredbooleanMarks the field required.
childrenReact.ReactNodeChild elements rendered inside the component.