VisorVisor
ComponentsForm

Field

A form field wrapper composing label, description, and error display.

Default

Your full name as it appears on your ID.

Sizes

Input and Textarea accept a size prop (sm, md, lg) that controls height, padding, and border-radius.

With Error

Horizontal

With Textarea

Maximum 200 characters.

Control Box

FieldControl is the box a control sits in. Put one Input, Textarea or Select inside: the control fills the box and goes bare, and the box draws the fill, the edge, the focus ring (2px on keyboard focus) and the invalid look, read from the control's aria-invalid. Pass tall for a Textarea, so the box grows with its text. FieldLabel optional adds the "optional" mark. Without FieldControl, Field renders exactly as above.

As it appears on your ID.

Glass and the Error Colour

Glass is off by default: the box is solid, with the shared control edge. Inside data-glass="on" (see Glass) it takes the glass layer's control fill, hover fill, ring, ink and blur. The error colour is a theme value, field.error-color (unset, --text-error), so a plain page draws the error line in red. Over a photo, red sinks into warm colours, so under glass the error line and the invalid edge take the glass layer's on-photo ink, and the icon and the edge carry the error.

In Five Looks

Field with its control box, valid and invalid, in each look on the theme picked in the docs. The Photo looks turn glass on over a photo. The specimen binds the kit's sizes and inks through the field tokens, as a theme would (see Theming below).

Today
Dark
Dark + Photo
Light
Light + Photo

Theming

A theme sets the label (size, weight, case, tracking, colour, the "optional" mark), the hint, the error line and the control box through the field component tokens. Each falls back to the look above, so a theme that binds none of them draws Field unchanged. See Component Tokens.

components:
  field:
    label-font-size: "9px"
    label-text-transform: uppercase
    label-letter-spacing: "0.12em"

Installation

npx visor add field

This copies two files into your project:

  • components/ui/field/field.tsx — the component
  • components/ui/field/field.module.css — the styles

Usage

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

<Field>
  <FieldLabel htmlFor="name">Name</FieldLabel>
  <Input id="name" placeholder="Jane Doe" />
  <FieldDescription>Your full name as it appears on your ID.</FieldDescription>
</Field>

API Reference

FieldProps

PropTypeDefaultDescription
orientation'vertical' | 'horizontal''vertical'Layout direction of the field group.
classNamestring—Additional CSS class names to merge onto the element.

FieldLabelProps

PropTypeDefaultDescription
optionalbooleanfalseRenders " optional" after the label text, inside the label, so the accessible name includes it.

FieldControlProps

PropTypeDefaultDescription
tallbooleanfalseLets the box grow with its content, for a Textarea.
childrenReact.ReactNode—One Input, Textarea or Select. It fills the box and goes bare; the box draws the fill, edge, focus ring and invalid look (from the control's aria-invalid).

FieldErrorProps

PropTypeDefaultDescription
errorsArray<{ message?: string } | undefined>—Array of error objects to display. Duplicates are deduplicated by message.
childrenReact.ReactNode—Custom error content. Takes precedence over the errors prop.

Sub-components

ComponentElementPurpose
Field<div>Wrapper grouping label, input, description, and error
FieldLabel<label>Semantic label linked to the input via htmlFor
FieldControl<div>The box a control sits in: fill, edge, focus ring, invalid look, glass under data-glass="on"
FieldDescription<p>Helper text providing additional context for the field
FieldError<div>Error message container with role="alert" for live announcements

Accessibility

  • Field renders as a <div> — pair with Fieldset for groups of related fields
  • FieldLabel renders a semantic <label> — always use htmlFor matching the control's id
  • FieldDescription renders with a generated id that can be referenced by aria-describedby on the input
  • FieldError renders with role="alert" so screen readers announce errors immediately
  • Set aria-invalid="true" on the input when showing a FieldError to communicate the invalid state; inside FieldControl the box reads it for the invalid look
  • FieldLabel optional puts "optional" inside the label, so the control's accessible name includes it
  • The FieldError icon is aria-hidden; the message carries the error
  • Inside FieldControl, keyboard focus draws a 2px ring on the box in every look, valid or invalid