Attribute Reference

Attribute Description
hx-boost progressively enhances anchors and forms to use AJAX requests
hx-classes timed modification of classes on an element
hx-confirm shows a confim() dialog before issuing a request
hx-delete issues a DELETE to the specified URL
hx-error-url a URL to send client-side errors to
hx-get issues a GET to the specified URL
hx-history-elt the element to snapshot and restore during history navigation
hx-include includes additional data in AJAX requests
hx-indicator the element to put the htmx-request class on during the AJAX request
hx-params filters the parameters that will be submitted with a request
hx-patch issues a PATCH to the specified URL
hx-post issues a POST to the specified URL
hx-prompt shows a prompt before submitting a request
hx-push-url pushes the URL into the location bar, creating a new history entry
hx-put issues a PUT to the specified URL
hx-select selects a subset of the server response to process
hx-sse-src establishes an SSE source for events
hx-swap-oob marks content in a response as being "Out of Band", i.e. swapped somewhere other than the target
hx-swap controls how the response content is swapped into the DOM (e.g. 'outerHTML' or 'beforeEnd')
hx-target specifies the target element to be swapped
hx-trigger specifies the event that triggers the request

CSS Class Reference

Class Description
htmx-indicator A dynamically generated class that will toggle visible (opacity:1) when a htmx-request class is present
htmx-request Applied to either the element or the element specified with hx-indicator while a request is ongoing
htmx-settling Applied to a target after content is swapped, removed after it is settled
htmx-swapping Applied to a target before any content is swapped, removed after it is swapped

HTTP Header Reference

Request Headers

Header Description
X-HTTP-Method-Override the HTTP verb for non-GET and POST requests
X-HX-Active-Element-Name the name of the active element if it exists
X-HX-Active-Element-Value the value of the active element if it exists
X-HX-Active-Element the id of the active element if it exists
X-HX-Current-URL the current URL of the browser
X-HX-Event-Target the id of the original event target
X-HX-Prompt the user response to an ic-prompt
X-HX-Request always true
X-HX-Target the id of the target element if it exists
X-HX-Trigger-Name the name of the triggered element if it exists
X-HX-Trigger the id of the triggered element if it exists

Response Headers

Header Description
X-HX-Push pushes a new url into the history stack
X-HX-Trigger allows you to trigger client side events, see the documentation for more info

Event Reference

Event Description
afterOnLoad.htmx triggered after an AJAX request has finished
afterSettle.htmx triggered after the DOM has settled
afterSwap.htmx triggered after new content has been swapped in
beforeOnLoad.htmx triggered before any response processing occurs
beforeRequest.htmx triggered before an AJAX request is made
beforeSwap.htmx triggered before a swap is done
configRequest.htmx triggered before the request, allows you to customize parameters, headers
historyCacheMiss.htmx triggered on a cache miss in the history subsystem
historyCacheMissError.htmx triggered on a unsuccessful remote retrieval
historyCacheMissLoad.htmx triggered on a succesful remote retrieval
historyRestore.htmx triggered when htmx handles a history restoration action
beforeHistorySave.htmx triggered before content is saved to the history cache
initSSE.htmx triggered when a new Server Sent Event source is created
load.htmx triggered when new content is added to the DOM
noSSESourceError.htmx triggered when an element refers to a SSE event in its trigger, but no parent SSE source has been defined
onLoadError.htmx triggered when an exception occurs during the onLoad handling in htmx
oobErrorNoTarget.htmx triggered when an out of band element does not have a matching ID in the current DOM
prompt.htmx triggered after a prompt is shown
responseError.htmx triggered when an HTTP response error (non-200 or 300 response code) occurs
sendError.htmx triggered when a network error prevents an HTTP request from happening
sseError.htmx triggered when an error occurs with a SSE source
swapError.htmx triggered when an error occurs during the swap phase
targetError.htmx triggered when an invalid target is specified