Skip to content
Ballpoint

Field

Labels, descriptions, red-pen errors, fieldsets and choice cards: shadcn's field layout, drawn.

From shadcn/ui
Book a call

Thirty minutes, no slides.

When
Time of day

An email the day before.

Installation

pnpm dlx shadcn@latest add @ballpoint/field

Usage

tsx
import { Field, FieldDescription, FieldError, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"

<Field data-invalid>
  <FieldLabel htmlFor="email">Email</FieldLabel>
  <Input id="email" aria-invalid />
  <FieldDescription>We only write when it matters.</FieldDescription>
  <FieldError>That email is missing its domain.</FieldError>
</Field>

Examples

Settings list

A fieldset of horizontal fields, each with a title, a hint and a switch.

Pen settings

Strokes draw themselves as they scroll into view.

Switch to the night paper after dark.

A quiet scratch while a line is drawn.

Several errors

Give FieldError a list of errors and it shows each distinct message once.

Shown beside your notes. You can change it later.

A whole form

Grouped fields, a radio set and a textarea, checked when submitted.

Book a lesson

Left-handed or right-handed, we have pens for both.

Which hand?

API reference

Field orientation
default "vertical"
"vertical" | "horizontal" | "responsive"

Label above the control, beside it, or beside it once the group is wide enough.

FieldLegend variant
default "legend"
"legend" | "label"

A fieldset title, or one sized like a label.

FieldError errors
{ message?: string }[]

Shows each unique message; children win if given.