Skip to content

Components

Field: the label, hint and message of every input

Field wraps every input, select and picker in an app built on Meadowstack: a visible label above it, a short hint under it, and an error message that says what to do. It wires the label, the hint and the error to the control for screen readers, so no form uses a placeholder as its label or shows an error only as a red border.

By Bohuslav PoláčekChecked

Juniper's lunch menu after Save with the third main left empty, and the starter's new purchase request without a supplier, rendered from the kit. The chosen day and dishes are written into their selects here; in the app the select fills in its own text.

What it is for, and what the preview shows

Field is the frame of one control: its label, the control, a hint under it and the error when there is one. It takes exactly one child, such as an Input, Select, NumberField, DatePicker, Textarea or Composer, and gives it an id, aria-describedby pointing at the hint and the error, aria-invalid while there is an error, and aria-required when the field is required.

The preview shows two forms. The lunch menu of Juniper, a restaurant in the demo, after Save with the third main left empty: the dish and its price each say what to do ("Choose a dish.", "Enter the dish's price."), and the soup's hint lists its allergens. Beside it, the starter's new purchase request with the supplier missing, a hint under the amount and a date picker. Every field there is required, so none carries an asterisk.

The rules, and where each one lives

  • Every input sits in a Field with a visible label. The root AGENTS.md (Accessibility, WCAG 2.2 AA). An own <input>, <select> or <textarea> in an app fails npm run check:markup (bare-control).
  • Messages say what to do. "Choose a dish.", not "Invalid value" (AGENTS.md, Forms and Copy). The messages live in the zod schema, and react-hook-form hands them to Field's error.
  • Required or optional, whichever is rarer. The asterisk marks required fields by default; a form where nearly everything is required marks the optional ones instead, with requiredMark={false} on the required fields and optional on the rest (GOV.UK's rule, in the kit's FieldProps).
  • Readable in every state. Labels, hints and placeholders at 12 and 13px are text-fg or text-fg-muted, never the lighter grey, in both themes (AGENTS.md, Accessibility; decision 0015).
  • Kit sizes. Controls are 32px tall, 28 when small, 40 on touch screens; an h-* class on a kit control fails the static audit (control-height).
  • Unsaved changes are kept. A form with unsaved changes blocks navigation and asks first (AGENTS.md, Forms: useBlocker with useConfirm).

What AI coding tools write instead

The manifest's replaces: a hand-written <label> with an error paragraph, and aria-describedby wired by hand. Asked for a form, an assistant writes a label, an input and a red paragraph under it, or skips the label and relies on the placeholder.

The pieces hold until someone uses a screen reader or copies a field: the for and the id drift apart, the error is not read out because nothing points at it, and a placeholder used as the label disappears as soon as someone types. Each form spaces its labels and hints differently, and the messages say what went wrong ("Invalid") instead of what to do. With Field the ids are wired once, the layout is the same in every form, and the assistant writes only the label and the message.

How to use it

The props, from its exported FieldProps:

  • label, and hideLabel to hide it from the eye but keep it for screen readers.
  • hint: short help under the control.
  • error: the message; while it is set, the control is marked invalid.
  • required, requiredMark (the asterisk, on by default) and optional, which marks the label as optional.
  • children: exactly one control.

With react-hook-form, spread register("title") on the control and pass errors.title?.message to error; a control without a native input, such as DatePicker, goes through a Controller. NumberField takes value (a number or null), onChange, min, max, step, unit and decimals. Next to a record, a PropertyList shows the facts and Field edits them in a form or a dialog. The pattern behind a whole form is the form pattern.

Its entry in the manifest

The component's rules as the kit's manifest states them, the same entry an AI coding tool reads.Read from the kit's component manifest when the site was built (126 components, packages/kit/src/components.json); the same entry answers an AI coding tool through the kit's MCP server.

Where it runs in the example apps

The example apps whose code renders Field, and in which modules, read from the demo's source.Read from the demo's source when the site was built: 9 of 9 example apps render <Field>, in the modules named here as each app's sidebar names them.

How the starter's form uses it

templates/starter/src/modules/requests/pages/request-form.tsx
<form id={formId} onSubmit={onSubmit} noValidate className="flex min-w-0 flex-col gap-5">
  <Field label="What do you want to buy?" required requiredMark={false} error={errors.title?.message}>
    <Input autoComplete="off" {...register("title")} />
  </Field>
  <Field label="Supplier" required requiredMark={false} error={errors.supplier?.message}>
    <Input autoComplete="organization" {...register("supplier")} />
  </Field>
  <div className="grid gap-5 sm:grid-cols-2">
    <Field
      label="Amount in euros"
      hint="Including VAT, whole euros."
      required
      requiredMark={false}
      error={errors.amount?.message}
    >
      <Input type="number" inputMode="numeric" min={1} step={1} {...register("amount")} />
    </Field>
    <Controller
      control={control}
      name="neededBy"
      render={({ field, fieldState }) => (
        <Field label="Needed by" required requiredMark={false} error={fieldState.error?.message}>
          <DatePicker
            value={field.value || null}
            onChange={(value) => field.onChange(value ?? "")}
            min={today()}
            placeholder="Pick a day"
          />
        </Field>
      )}
    />
  </div>
  <Field
    label="Why does the team need it?"
    hint="One or two sentences for the approver: what it is for and what happens without it."
    required
    requiredMark={false}
    error={errors.reason?.message}
  >
    <Textarea rows={4} {...register("reason")} />
  </Field>
</form>
The starter's purchase request: each control registered with react-hook-form inside its Field, the message from the zod schema, a hint on the amount and the reason, and the date picker through a Controller.

Questions

Can the placeholder be the label?

No. Every input sits in a Field with a visible label. A placeholder disappears as soon as someone types, and people who come back to a half-filled form no longer see what a field asks for.

What should an error message say?

What to do, in one short sentence, such as Choose a dish or Write who you are buying from. Not what went wrong, such as Invalid value.

How does a screen reader hear the hint and the error?

Field gives the control an id, points aria-describedby at the hint and the error, and sets aria-invalid while there is an error, so both are read with the field.

Should required fields get an asterisk?

By default, yes. When nearly every field is required, mark the optional ones instead: requiredMark set to false on the required fields and optional on the rest. The control gets aria-required either way.

Can one Field hold two inputs?

No. A Field takes exactly one control. A dish and its price are two Fields side by side in a grid, and a whole group of fields goes under a Section.

Two ways

Build it yourself, or have it built

  • Build it yourself

    Build your app on the framework

    Get the codebase these apps stand on and build yours with Claude Code, Cursor or Codex.

    One payment, lifetime updates

    Get the framework
  • Have it built

    Have us build your app

    Tell us how your team works. We plan the app with you and build it on the same framework at a fixed price.

    After launch, Care keeps it improving, from €99 a month.

    from €1,990

    Describe your app