Skip to content
Home Theme Gallery

HTMX forms

Every value-carrying Home-UI control is form-associated through ElementInternals.setFormValue. Give it a name and it submits like a native <input>: HTMX serialises the form as usual, and the Go server reads ordinary form fields. No adapter, no hidden input, no JavaScript of yours.

<form hx-post="/race-entry">
<hui-date-picker name="raceDate" value="2026-09-20"></hui-date-picker>
<hui-combobox name="courseId" value="7"></hui-combobox>
<hui-button type="submit">Save</hui-button>
</form>

Submitting that form sends raceDate=2026-09-20 and courseId=7 in the request body.

A form the host rendered
Source
<form>
<hui-field style="max-width:22rem">
<span data-label>Project name</span>
<hui-input data-control name="project" value="Home-UI"></hui-input>
<span data-description>Shown in the sidebar.</span>
</hui-field>
<hui-input name="email" type="email" value="dev@example.com" aria-label="Email"></hui-input>
<hui-button type="submit">Save</hui-button>
</form>
InputSubmits
nameThe field name. A control with no name submits nothing.
valueThe current value. Setting the property updates the form value immediately.
disabledExcluded from submission, matching native controls.
  • Validation is the host’s. A component reports its internal constraint validity to the form (setValidity), so native form validation and hui-button type="submit" behave as they do on a native form — but business rules live on the server.
  • Multiple controls sharing a name submit multiple values, as native controls do. hui-toggle-group in multiple mode is the built-in example: one entry per pressed item, under the same name.
  • hui-button itself carries no value; it is form-associated only so that type="submit" and type="reset" can drive the surrounding form. Use requestSubmit() and reset() semantics through it rather than a plain <button> if you want the component’s pressed offset.

A native <input type="reset"> or hui-button type="reset" resets every associated control to the value captured from its value attribute when it connected. The component does not hold the form’s own default; the server-rendered attribute is the default.

When HTMX replaces a region, controls are removed and re-created. A removed control leaves no stale entry in the form’s submitted data, and a re-created one re-associates with its form on connect. See HTMX swaps.