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.
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>The rules
Section titled “The rules”| Input | Submits |
|---|---|
name | The field name. A control with no name submits nothing. |
value | The current value. Setting the property updates the form value immediately. |
disabled | Excluded 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 andhui-button type="submit"behave as they do on a native form — but business rules live on the server. - Multiple controls sharing a
namesubmit multiple values, as native controls do.hui-toggle-groupin multiple mode is the built-in example: one entry per pressed item, under the same name. hui-buttonitself carries no value; it is form-associated only so thattype="submit"andtype="reset"can drive the surrounding form. UserequestSubmit()andreset()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.
After a swap
Section titled “After a swap”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.