Components

Field

The words around a control: a label, help text and an error, stacked or in a row, grouped in sets with a legend. It is layout, so the only drawings are the wavy red pencil underline of an error and the hand-drawn card around a choice (a label that wraps a radio or checkbox with its own title and help).

Install

terminal
npx shadcn@latest add @wobko/field

First time here? Add the registry to components.json first. How to install

Examples

Default

A set of labeled controls: a legend in the script font, fields that stack label, control and help, and the gaps between them. Nothing is drawn but the controls; Field is layout and words.

Orientations

`vertical` (label above), `horizontal` (label beside a switch or checkbox, with FieldContent holding the words) and `responsive` (vertical until its FieldGroup is md wide, using a container query, so it follows the box, not the screen).

Choice cards

A FieldLabel around a whole Field becomes a hand-drawn card; when the radio or checkbox inside it is checked the card gets a highlighter wash and a felt box. Click anywhere on a card.

Errors and validation

`FieldError` takes children or an `errors` array: one message is text, several are a list, duplicates collapse. It is announced as an alert and wears a wavy red pencil underline; `data-invalid` on the Field turns the label red, `aria-invalid` on the control draws its box red.

Checkout form

shadcn's `field-demo`, the big one: two FieldSets with legends, a three-column row of Month, Year and CVV, a checkbox row, a comment box and a pair of buttons, all separated by a FieldSeparator.

Input

shadcn's `field-input`: a description can sit under the control (Username) or between the label and the control (Password); the order in the JSX is the order on the page.

Textarea

shadcn's `field-textarea`: a labeled ruled box with a hint underneath. `rows` sets the height, as on a plain textarea.

Fieldset

shadcn's `field-fieldset`: a real `<fieldset>` with a legend and a line of help, a full-width field and a two-column row of City and Postal Code.

Radio

shadcn's `field-radio`: a RadioGroup inside a FieldSet, each option a horizontal Field with the button first and its label after it.

Checkbox

shadcn's `field-checkbox`: a legend styled as a label over a tight group of boxes, then, below a separator, one box whose label and description share a FieldContent column.

Switch

shadcn's `field-switch`: label and description in a FieldContent column, the switch at the far end of a horizontal Field. Click the words or the switch.

Slider

shadcn's `field-slider`: a range slider has no single control to label, so FieldTitle names it (and `aria-label` goes on the slider). The description reads the two values out.

Select

shadcn's `field-select`: a Radix Select under a label with a hint. The label points at the trigger (`htmlFor` and `id`, which the original leaves out), so a click on the word opens the list.

Choice card

shadcn's `field-choice-card`: a FieldLabel wrapped around a whole Field makes the row one big target. Here each card is a small hand-drawn slip, and the checked one gets the highlighter wash.

Field group

shadcn's `field-group`: FieldGroups stack fields and FieldSets, and `data-slot="checkbox-group"` tightens the gap between boxes. The first box is checked and disabled, the second set has a link in its help line.

Responsive layout

shadcn's `field-responsive`: `orientation="responsive"` stacks label above control on a narrow container and puts them side by side once the FieldGroup is wide enough. It answers to the container, not the viewport, so resize the preview.

API reference

FieldLegend

The title of a set (a `<legend>`).

PropTypeDefaultDescription
variant"legend" | "label""legend"`legend` is set in the script font; `label` like a Label.

Field

One labeled thing: a role=group with the control, label, help and error in it. `data-invalid="true"` turns its words red; `data-disabled="true"` dims the label.

PropTypeDefaultDescription
orientation"vertical" | "horizontal" | "responsive""vertical"Label above, label beside, or vertical until the FieldGroup is md wide (a container query).

FieldLabel

A Label. When a direct child is a whole `Field` it turns into a choice card: a hand-drawn box that gets a highlighter wash and a felt outline when a control inside it is checked.

PropTypeDefaultDescription
cardboolean-Force the choice-card drawing on or off (default: on when a direct child is a Field). Use it when the Field is wrapped in your own component.
seedstring | number-Pins the hand of the card.

FieldError

The message under a field, announced as an alert and underlined with a wavy red pencil line. Renders nothing when there is nothing to say.

PropTypeDefaultDescription
errorsArray<{ message?: string } | undefined>-react-hook-form / zod style errors: one message is text, several a bullet list, duplicates once.
childrenReactNode-Your own message; wins over `errors`.
seedstring | number-Pins the hand of the underline.

Accessibility

  • Field is a role=group; a FieldLabel is a real <label> (use htmlFor + id), so a click on it focuses or toggles the control. Wrap radios and checkboxes in a FieldSet with a FieldLegend so the group has a name.
  • FieldError is role="alert": it is announced when it appears. Point the control at it with aria-describedby and set aria-invalid, so the control's own box turns red as well (hue is never the only cue: the message, the wavy underline and the bang of the field say it too).
  • A choice card is one big label: clicking anywhere on it toggles its control, and the checked state is shown by the wash and the felt box, not by color alone (the radio or checkbox inside shows it too). In Windows high contrast the checked card becomes a Highlight block.
  • Disabling: set `data-disabled="true"` on the Field (the label goes graphite) AND `disabled` on the control. A `disabled` FieldSet disables the controls natively, but the drawn controls choose their dashed disabled drawing from their own props (or their root's), not from an ancestor fieldset: pass `disabled` to each.
  • `responsive` uses a container query on the FieldGroup, so it reacts to the width of the form, not of the screen.
  • Right-to-left: everything uses logical properties; the error underline is symmetric.

Source

The files the CLI copies into your project.

Loading the source