molecules
Form field
A labelled input or textarea with a help line and a hidden error line, wired together with aria-describedby.
Specimens
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"
}
}) }}{{ 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
| Param | Type | Description |
|---|---|---|
id | string | Required. Input id. The error paragraph is {id}-error and the help paragraph is {id}-help. |
name | string | Required. Form field name. |
label | string | Required. Visible label text. |
type | string | Defaults to text. textarea renders a <textarea>; any other value renders <input type="...">. |
required | boolean | Defaults to false. |
help | string | Optional help text. When set, {id}-help is added to aria-describedby. |
autocomplete | string | Optional. Passed to <input> only. |
rows | number | Defaults to 8. <textarea> only. |
styles | object | Slot map. See the slot table. |
| Slot | Element |
|---|---|
field | The control (<input> or <textarea>). |
label | The <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.