GOTHUI / DOCUMENTATION
Forms that work with the browser.
Native submission first. Validation and persistence belong to your application.
Keep the native contract
Use Form with a real action and method. Give each submitted control a name, each input an accessible label, and each action an explicit button type. Browser validation improves feedback; always validate again on the server.
@components.Form(components.FormProps{
Action: "/projects", Method: components.MethodPost,
}) {
@components.Input(components.InputProps{
Name: "name", Label: "Project name", Required: true,
})
@components.Button(components.ButtonProps{
Text: "Create project", Type: components.ButtonTypeSubmit,
Primary: true,
})
}
Make errors actionable
Preserve safe submitted values. Mark invalid controls and associate help and error text using aria-describedby. An ErrorSummary should link to the relevant field IDs. Keep error wording specific enough to help someone recover.
The form lab includes native constraints and server validation. The multi-step example revalidates all values at the final step rather than trusting earlier screens.
Bound requests and uploads
Set request body limits before parsing. FileInput and multipart forms provide browser controls and encoding; they do not authorize, validate, or persist uploaded files. The CSV example previews a bounded file without saving it.
Own request protection
Authentication, authorization, CSRF defenses, cookie security, and idempotency belong to the application. These demos use same-origin checks and bounded requests. Their sample cookie state is not an authentication or persistence design.
Enhance progressively
Provide working native routes before adding HxPost, HxTarget, or other optional attributes. See the HTMX guide for full-page and fragment response handling.