GOTHUI / DOCUMENTATION
Enhance a working page.
Use optional HTMX attributes with explicit full-page and fragment responses.
Optional means application-owned
GothUI emits HTMX attributes but does not bundle HTMX or any other JavaScript. This website’s public demos work with native HTML. In an enhanced app, load your own pinned, locally served HTMX runtime and use an appropriate Content Security Policy.
components.ButtonProps{
Text: "Load details",
Type: components.ButtonTypeButton,
HxGet: "/details",
HxTarget: "#details",
HxSwap: "innerHTML",
}
A button that only loads a fragment still needs an equivalent ordinary-page link or form for users without scripts. The inline editing example uses native form actions alongside HTMX attributes.
Respond with the right representation
Use render.HTML with the complete document and optional fragment. It selects the fragment for supported HTMX requests and emits the appropriate Vary headers. History restoration must receive a complete page.
err := render.HTML(w, r, http.StatusOK, fullPage, fragment)
if err != nil {
log.Printf("render: %v", err)
}
Handle validation statuses
HTMX does not swap every error response by default. The editing example returns invalid forms with status 200 for HTMX fragments and status 422 for native pages, so default HTMX handling displays its errors. If your application instead returns a 422 fragment, configure response handling deliberately. Keep the native full-page response functional.
Changing the document theme
ThemeToggle submits a native POST. The example handler saves its theme cookie and redirects to a cleaned local URL. For an enhanced request it uses HX-Redirect on a successful non-3xx response, so the browser performs a real navigation with the new root theme and head.
It does not attempt an outerHTML replacement of the root HTML element. URLs and headers are untrusted inputs: validate the same-origin destination before using them.
Reference
Consult the official HTMX documentation for runtime configuration, CSP, response handling, and history behavior. The library’s browser suite tests a separate consumer fixture; it does not add that runtime to the shipped website.