hx

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttrGet         = "hx-get"
	AttrPost        = "hx-post"
	AttrPushUrl     = "hx-push-url"
	AttrSelect      = "hx-select"
	AttrSelectOob   = "hx-select-oob"
	AttrSwap        = "hx-swap"
	AttrSwapOob     = "hx-swap-oob"
	AttrTarget      = "hx-target"
	AttrTrigger     = "hx-trigger"
	AttrVals        = "hx-vals"
	AttrBoost       = "hx-boost"
	AttrConfirm     = "hx-confirm"
	AttrDelete      = "hx-delete"
	AttrDisable     = "hx-disable"
	AttrDisabledElt = "hx-disabled-elt"
	AttrDisinherit  = "hx-disinherit"
	AttrEncoding    = "hx-encoding"
	AttrExt         = "hx-ext"
	AttrHeaders     = "hx-headers"
	AttrHistory     = "hx-history"
	AttrHistoryElt  = "hx-history-elt"
	AttrInclude     = "hx-include"
	AttrIndicator   = "hx-indicator"
	AttrInherit     = "hx-inherit"
	AttrParams      = "hx-params"
	AttrPatch       = "hx-patch"
	AttrPreserve    = "hx-preserve"
	AttrPrompt      = "hx-prompt"
	AttrPut         = "hx-put"
	AttrReplaceUrl  = "hx-replace-url"
	AttrRequest     = "hx-request"
	AttrSync        = "hx-sync"
	AttrValidate    = "hx-validate"
	AttrVars        = "hx-vars"
)

Attr* constants are htmx attribute names. Using these constants prevents typos and enables LSP autocompletion.

View Source
const (
	SwapInnerHtml   = "innerHTML"
	SwapOuterHtml   = "outerHTML"
	SwapBeforeBegin = "beforebegin"
	SwapAfterBegin  = "afterbegin"
	SwapBeforeEnd   = "beforeend"
	SwapAfterEnd    = "afterend"
	SwapDelete      = "delete"
	SwapNone        = "none"
)

Swap* constants are valid values for the hx-swap attribute.

View Source
const (
	EventAbort                 = "htmx:abort"
	EventAfterOnLoad           = "htmx:after-on-load"
	EventAfterProcessNode      = "htmx:after-process-node"
	EventAfterRequest          = "htmx:after-request"
	EventAfterSettle           = "htmx:after-settle"
	EventAfterSwap             = "htmx:after-swap"
	EventBeforeCleanupElement  = "htmx:before-cleanup-element"
	EventBeforeOnLoad          = "htmx:before-on-load"
	EventBeforeProcessNode     = "htmx:before-process-node"
	EventBeforeRequest         = "htmx:before-request"
	EventBeforeSend            = "htmx:before-send"
	EventBeforeSettle          = "htmx:before-settle"
	EventBeforeSwap            = "htmx:before-swap"
	EventConfigRequest         = "htmx:config-request"
	EventConfirm               = "htmx:confirm"
	EventHistoryCacheError     = "htmx:history-cache-error"
	EventHistoryCacheMiss      = "htmx:history-cache-miss"
	EventHistoryCacheMissError = "htmx:history-cache-miss-error"
	EventHistoryRestore        = "htmx:history-restore"
	EventLoad                  = "htmx:load"
	EventNoSseSourceError      = "htmx:no-sse-source-error"
	EventOnLoadError           = "htmx:on-load-error"
	EventOobAfterSwap          = "htmx:oob-after-swap"
	EventOobBeforeSwap         = "htmx:oob-before-swap"
	EventOobErrorNoTarget      = "htmx:oob-error-no-target"
	EventPrompt                = "htmx:prompt"
	EventResponseError         = "htmx:response-error"
	EventSendError             = "htmx:send-error"
	EventSseError              = "htmx:sse-error"
	EventSseOpen               = "htmx:sse-open"
	EventSseMessage            = "htmx:sse-message"
	EventSwapError             = "htmx:swap-error"
	EventTargetError           = "htmx:target-error"
	EventTimeout               = "htmx:timeout"
	EventValidationValidate    = "htmx:validation:validate"
	EventValidationFailed      = "htmx:validation:failed"
	EventValidationHalted      = "htmx:validation:halted"
	EventXhrAbort              = "htmx:xhr:abort"
	EventXhrLoadend            = "htmx:xhr:loadend"
	EventXhrLoadstart          = "htmx:xhr:loadstart"
	EventXhrProgress           = "htmx:xhr:progress"
)

Event* constants are htmx event names. Use these constants with AttrOn for type-safe inline event handlers.

Variables

This section is empty.

Functions

func AttrOn

func AttrOn(event string) string

AttrOn generates an hx-on attribute for inline event handlers. The event parameter should be the event name (e.g., "click", "mouseover", "htmx:before-swap").

Example:

AttrOn("click")            // returns "hx-on:click"
AttrOn("htmx:before-swap") // returns "hx-on:htmx:before-swap"

func Script

func Script() h.Node

Script returns the htmx JavaScript as a <script> element. Use this to include htmx in your pages.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL