datui
Color scheme

Forms

FormItem

Field wrapper with label, helper or error text, required marker and optional remove action.

import { FormItem, FormItemTop, FormItemTopLabel, FormItemTopAside } from "datui";

Playground

Helper text
<FormItem top="Name" bottom="Helper text" status="default" />

Examples

Label, hint and error

datui controls inside are wired to the label and bottom text automatically.

We never share it

Custom header

Compose FormItemTop with a label and an aside such as a counter.

0/140

Accessibility

  • A text top renders a <label> pointing at the control id (generated, or htmlFor).
  • bottom is linked through aria-describedby; with status="error" it gets role="alert" and the control gets aria-invalid.
  • required sets required on the control; the * marker is aria-hidden.
  • Custom controls can join the wiring through useFormItemControl().

API

FormItem

Field wrapper: label (`top`), control (`children`), helper/error text (`bottom`). datui text controls inside (Input, Textarea, Search, NativeSelect, Select, SelectMimicry) are wired automatically: id ↔ label, `aria-describedby` ↔ bottom, `aria-invalid` from `status`, `required`. Custom controls call `useFormItemControl()`.

PropTypeDefaultDescription
bottomReactNode—Helper or error text under the control, linked through `aria-describedby`.
bottomIdstring—Id of the bottom text.
classNamestring—
htmlForstring—Id of the control. Defaults to a generated id that datui controls inside pick up automatically.
noPaddingbooleanfalseRemoves the horizontal padding.
onRemove((event: MouseEvent<HTMLButtonElement, MouseEvent>) => void)—
removableboolean | "indent"—`true` shows a remove button after the content; `"indent"` only reserves its space for alignment.
removeLabelstring—Accessible label of the remove button.
requiredbooleanfalseMarks the label with `*` and sets `required` on the control.
statusFormFieldStatusdefaultValidation state passed to the control (border + `aria-invalid`) and bottom text color.
topReactNode—Label. A string/number renders a `<label>` for the control; pass a `FormItemTop` for custom headers.
topIdstring—Id of the label element.
topMultilinebooleanfalseLet a text `top` wrap instead of truncating.

FormItemTop

Header row of a FormItem: a `FormItemTopLabel` plus optional `FormItemTopAside`.

PropTypeDefaultDescription
classNamestring—

FormItemTopLabel

Field label. Renders `<label>` when it has a control to point at, otherwise `<span>`.

PropTypeDefaultDescription
classNamestring—
htmlForstring—Id of the labelled control. Inside a FormItem it defaults to the item's control id.
multilinebooleanfalseAllow wrapping instead of truncating.
requiredboolean—Show the required marker. Inside a FormItem it defaults to the item's `required`.

FormItemTopAside

End-aligned secondary header content, e.g. a character counter (give dynamic counters `aria-live="polite"`).

PropTypeDefaultDescription
classNamestring—