labsUI

Field

Label, control, description and error as one unit. Controls inside (Input, Textarea, Select, Checkbox, Switch, RadioGroup) get id, aria-describedby, aria-invalid and required automatically; errors spring in and are announced.

npx @kznlabs/labsui add field

Shown on your clips and profile.

<Field>

Label, control, description and error as one unit, with ids and ARIA wired automatically.

  • children*
    ReactNode

    One form control; it picks up id, aria and state from the Field.

  • description
    ReactNode

    Hint under the control.

  • disableddefault false
    boolean

    Dims the label and disables the control.

  • error
    ReactNode

    Shown under the control and marks it aria-invalid. Springs in and out.

  • id
    string

    Use when the control renders its own id (it must match).

  • label
    ReactNode

    Label wired to the control's id.

  • orientationdefault "vertical"
    "vertical" | "horizontal"

    "horizontal": control first, label beside it (Checkbox, Switch).

  • requireddefault false
    boolean

    Marks the label and makes the control required.

PropTypeDefault
children*

One form control; it picks up id, aria and state from the Field.

ReactNode—
description

Hint under the control.

ReactNode—
disabled

Dims the label and disables the control.

booleanfalse
error

Shown under the control and marks it aria-invalid. Springs in and out.

ReactNode—
id

Use when the control renders its own id (it must match).

string—
label

Label wired to the control's id.

ReactNode—
orientation

"horizontal": control first, label beside it (Checkbox, Switch).

"vertical" | "horizontal""vertical"
required

Marks the label and makes the control required.

booleanfalse

useFieldControl()

For controls: fills id, aria-describedby, aria-invalid, required and disabled from the enclosing <Field>. Explicit props win. Outside a Field it returns the props unchanged.

useFieldControl(props: Props) => Props

* required. Every component also takes className.