Skip to main content

Form Field

Combines label, input, hint, and error into a consistent field layout.

Preview ยท Form Field

Codeโ€‹

<div class="vstack" style="max-width:320px">
<div data-field>
<label for="company">Company name</label>
<input id="company" type="text" placeholder="Acme Corp" />
<span data-hint>Used for tenant identification.</span>
</div>
<div data-field="error">
<label for="email2">Email</label>
<input id="email2" type="email" aria-invalid="true" />
<span class="error">Please enter a valid email.</span>
</div>
</div>

Propsโ€‹

PropTypeDefaultDescription
labelstringโ€”Field label
hintstringโ€”Helper text
errorstringโ€”Error message
requiredbooleanfalseRequired indicator

Accessibilityโ€‹

  • PrimusField / primus-form-field renders a <div data-field> wrapper with correct for/id associations
  • Error text is wrapped in role="alert" so it is announced immediately when it appears
  • Hint text uses data-hint โ€” linked to the input via aria-describedby
  • Required fields get aria-required="true" automatically when required prop is set
Version history

See the Changelog for version history and breaking changes.