Field

A field puts a label above one control, with help or an error below. The control inside is wired to that text for you.

Previewapps/web/components/ui/KbField.tsx

Controls in a field

Input, select and textarea all work inside a field.

One line, shown in the queue.

Show code
<KbField label="Subject" htmlFor="s" help="One line."><KbInput id="s" /></KbField>
<KbField label="Team" htmlFor="t"><KbSelect id="t">…</KbSelect></KbField>
<KbField label="Note" htmlFor="n"><KbTextarea id="n" /></KbField>

Help and error wiring

Clear the box to see the error. The error replaces the help, is announced as an alert, sets aria-invalid on the input and is linked with aria-describedby. Say what happened and what to do; don't use red alone.

Show code
<KbField label="Workspace name" htmlFor="ws" help="Shown to your team." error={name.trim() === "" ? "Enter a workspace name so your team can find it." : undefined}>
  <KbInput id="ws" value={name} onChange={…} />
</KbField>