Skip to main content

molecules

Form field

A labelled input or textarea with a help line and a hidden error line, wired together with aria-describedby.

Specimens

Email input

We reply within two days.

{{ Field.render({
  id: "specimen-email",
  name: "email",
  type: "email",
  label: "Email",
  autocomplete: "email",
  required: true,
  help: "We reply within two days.",
  styles: {
    label: "block text-sm text-neutral-300",
    field: "w-full border-b border-neutral-500 bg-transparent py-2 text-neutral-100"
  }
}) }}
Textarea
{{ Field.render({
  id: "specimen-message",
  name: "message",
  type: "textarea",
  label: "Message",
  rows: 4,
  styles: {
    label: "block text-sm text-neutral-300",
    field: "w-full border border-neutral-500 bg-transparent p-2 text-neutral-100"
  }
}) }}

Params

ParamTypeDescription
idstringRequired. Input id. The error paragraph is {id}-error and the help paragraph is {id}-help.
namestringRequired. Form field name.
labelstringRequired. Visible label text.
typestringDefaults to text. textarea renders a <textarea>; any other value renders <input type="...">.
requiredbooleanDefaults to false.
helpstringOptional help text. When set, {id}-help is added to aria-describedby.
autocompletestringOptional. Passed to <input> only.
rowsnumberDefaults to 8. <textarea> only.
stylesobjectSlot map. See the slot table.
SlotElement
fieldThe control (<input> or <textarea>).
labelThe <label>.

The molecule has no baseline styling: the caller sets both slots, including the focus ring and invalid state.

Notes

The error paragraph stays hidden until the form script fills it. Every specimen needs a unique id, because the id feeds the label, the description, and the error line.