Field

Free

The frame every PixilUI field shares: a label row, a well with a rim you can see on white, and a message that says what's wrong in plain words, wired for screen readers.

npx shadcn@latest add https://pixilui.com/r/field.json

Preview

One field frame: a rim you can see, and words that say what's wrong.
Size

When to use

Use it when

  • Building your own control from the parts (FieldControl, FieldInput, FieldPrefix, FieldSuffix, FieldStatus) when Input, Textarea or the others do not fit.

Use something else when

  • A plain text field: use Input, which is this frame already wired.

Installation

Terminal
npx shadcn@latest add https://pixilui.com/r/field.json

Adds field.tsx, and installs clsx and tailwind-merge. The URL works in any app with a components.json, with no registry to add first.

Usage

example.tsx
import { Field } from "@/components/pixilui/field";

<Field>Save changes</Field>

Fills its container's width; the label row and the message wrap.

API reference

PropTypeDefault
childrenRequiredReactNode–The control: a FieldControl holding the input and its parts.
labelReactNode–The label above the field. Leave it out when the place already names it, and give the input an aria-label.
hintReactNode–Right of the label: "Optional", or anything short.
count{ value: number; max?: number; format?: (value: number, max?: number) => string }–A counter in the hint's place: the characters typed and the limit. It turns orange at 90% of the limit.
descriptionReactNode–Help under the field. An error takes its place while there is one.
errorReactNode–What is wrong, in plain words. Marks the input invalid.
reserveMessageboolean–Keep an (empty) message line in the markup even with no help, for a field whose rule may speak later.

Also takes every native <label> attribute, and a ref.

Keyboard

TabMoves into the input; the frame itself never takes focus.

Accessibility

  • The label names the input (aria-labelledby) and the help or error describes it (aria-describedby), so a hint or a counter is never read as its name.
  • An error sets aria-invalid and says what is wrong in words; the color is never the only sign.
  • useFieldValidation runs a rule on blur and Enter and counts errors so the well shakes once for each.

Motion

  • The rim darkens in 150ms on hover; focus is a plain 1px ring with no motion.
  • An error shakes the well once, 4px over 320ms. Reduced motion: no shake, the ring and the words still say it.
InputA field that checks what you typed and says what's wrong in words.
TextareaGrows as you write, with a counter that warns near the limit.
Search fieldEsc clears, and Enter waits for composition to finish.

PixilUI Pro opens soon. The first 20 licenses are $99.