Skip to content
Forms

Field

A label, one control, a hint and an error, wired together for screen readers.

import { Field } from "@flinbu/seed";

Hint, error, optional and required

Shown to your team and clients.

Enter an email like name@company.com.

Optional

Markdown works.

import { Field, Input, Textarea } from "@flinbu/seed";

<div className="grid w-full max-w-xl grid-cols-1 gap-base sm:grid-cols-2">
  <Field label="Workspace name" hint="Shown to your team and clients." required>
    <Input defaultValue="flinbu" />
  </Field>
  <Field label="Email" error="Enter an email like name@company.com.">
    <Input type="email" defaultValue="ana@" />
  </Field>
  <Field label="Website" labelAside="Optional">
    <Input placeholder="https://" />
  </Field>
  <Field label="Notes" hint="Markdown works.">
    <Textarea placeholder="What changed and why" />
  </Field>
</div>

Use it for

  • Around every Input, Textarea, Select, Checkbox or Switch that needs a label.

Use something else for

  • Putting two controls in one Field: use one Field each.

Props

PropTypeDefaultDescription
labelReactNodenoneThe visible label.
labelAsideReactNodenoneSmall text at the right of the label, like Optional.
hintReactNodenoneHelper text under the control.
errorReactNodenoneError message; marks the control invalid.
requiredbooleannoneAsterisk on the label and required on the control.
disabledbooleannoneDisables the control and dims the label.
childrenReactElementnoneExactly one control.

Accessibility

  • The label points at the control; hint and error are linked with aria-describedby.
  • error marks the control invalid and is read with it.