Skip to content
Pixelbits
Docs / Field
Forms

Field

Label, control, helper text and error in one, with the accessibility wiring done: the label points at the control, the text is linked with aria-describedby, and an error sets aria-invalid.

We never share it.

Installation

npm: import
import { Field } from "pixelbits/field";
shadcn: copy the source
npx shadcn add https://pixelbits.ali-moradi-develop.com/r/field.json

API

<Field>

Label, control, helper text and error in one, with the accessibility wiring done: the label points at the control, the text is linked with aria-describedby, and an error sets aria-invalid.

Example
<Field label="Email" description="We never share it." error={errors.email} required>
  <Input type="email" name="email" />
</Field>
PropTypeDefaultDescription
label*ReactNode—

Visible label, linked to the control with for/id.

descriptionReactNode—

Helper text under the control, linked with aria-describedby.

errorReactNode—

Error message. When set, the control is marked aria-invalid and the message replaces the description and is announced.

requiredbooleanfalse

Marks the control as required and shows a small accent square after the label.

disabledbooleanfalse

Disables the control and dims the label.

idstring—

Id of the control. Generated when omitted.

children*ReactNode—

The control: Input, Textarea, Select, Combobox, Slider…

Also accepts every prop of Omit<HTMLAttributes<HTMLDivElement>, "children">.