Skip to content
Logic2BUI

Search docs

Search components and documentation

New
Menu

Field

Composable primitives for laying out a form field without requiring react-hook-form.

This is your public display name.

Installation

npx logic2b@next add field

Usage

import { Field, FieldDescription, FieldError, FieldGroup, FieldLabel } from "@/components/ui/field"

<FieldGroup>
  <Field>
    <FieldLabel htmlFor="username">Username</FieldLabel>
    <Input id="username" placeholder="shadcn" />
    <FieldDescription>This is your public display name.</FieldDescription>
  </Field>
  <Field>
    <FieldLabel htmlFor="email">Email</FieldLabel>
    <Input id="email" type="email" aria-invalid />
    <FieldError>Please enter a valid email address.</FieldError>
  </Field>
</FieldGroup>

Use field for simple forms or to wrap a single control without react-hook-form. For forms that need schema validation wired to field state, use the form component (react-hook-form + zod) instead.

Examples

Horizontal

Pair a control with a label and description side by side.

Require a second step when signing in.

Field Set

Group related fields under a FieldLegend.

Shipping address

Where should we send your order?

Live playground

Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.

Generated JSX
<FieldGroup>
  <Field
    orientation="vertical"
  >
    <FieldLabel
      htmlFor="playground-email"
    >Email</FieldLabel>
    <input
      id="playground-email"
      type="email"
      defaultValue="team@logic2b.com"
      className="h-9 rounded-md border bg-background px-3 text-sm"
     />
    <FieldDescription>Used for release notifications.</FieldDescription>
  </Field>
</FieldGroup>

API reference

Generated from the public TypeScript exports in src/ui/field.tsx.

View JSON

Field

Component
Props: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>
PropTypeRequiredDefaultDescription
orientationnull | "horizontal" | "vertical" | "responsive"No"vertical"—

FieldLabel

Component
Props: React.ComponentProps<typeof Label>

FieldDescription

Component
Props: React.ComponentProps<"p">

FieldError

Component
Props: React.ComponentProps<"div"> & { errors?: Array<{ message?: string } | undefined> }
PropTypeRequiredDefaultDescription
errorsArray<{ message?: string } | undefined>No——

FieldGroup

Component
Props: React.ComponentProps<"div">

FieldSeparator

Component
Props: React.ComponentProps<"div">

FieldSet

Component
Props: React.ComponentProps<"fieldset">

FieldLegend

Component
Props: React.ComponentProps<"legend"> & { variant?: "legend" | "label" }
PropTypeRequiredDefaultDescription
variant"legend" | "label"No"legend"—

FieldContent

Component
Props: React.ComponentProps<"div">

FieldTitle

Component
Props: React.ComponentProps<"div">

Accessibility contract

Machine-readable behavior and consumer responsibilities for field.

View JSON
Support
Authored behavior
Pattern
labelled form field
HTML fieldset/label

Built-in semantics

  • Field labels, descriptions and validation messages can be associated with the nested native control.

Consumer responsibilities

  • Connect help and error text with aria-describedby and set aria-invalid only while the value is invalid.