Skip to content
Cynco UI

Make it yours

Accent A
Theme T
Radius R
Density D
Documents L

Every demo on the site follows these, and Copy prompt carries them to your agent. Light and dark stay on the toggle beside this.

Field

A form field: label, description, control and error, with the ids wired between them.

import { Field } from "@cynco-labs/ui";

Example

Use

Every labelled control. It replaces hand-wiring htmlFor, aria-describedby and aria-invalid on each field.

Props

Field (optional invalid) around FieldLabel (optional required, hint), FieldDescription, FieldControl wrapping the control, and FieldError while invalid.

Prop Type Default
invalid boolean false

Also accepts ComponentProps<"div">, and className.

Accessibility

FieldLabel is a native label bound to the control by id, so clicking it focuses the control and the control is named by it. FieldDescription and, while the field is invalid, FieldError are pointed at by the control's aria-describedby, and the control carries aria-invalid. required adds an sr-only "(required)" beside the asterisk. The hint tooltip is a real button, so keyboard focus opens it and Escape closes it.

Notes

FieldControl is what hands the control its id, aria-describedby and aria-invalid, so the wiring cannot be forgotten. The description and the hint tooltip render outside the <label>, so the control's accessible name stays the label text. FieldError pairs a warning glyph with the words, so the error never rests on colour.

Source on GitHub Demo source Markdown