Reference

Contents

Core Attribute Reference

The most common attributes when using htmx.

AttributeDescription
hx-getissues a GET to the specified URL
hx-postissues a POST to the specified URL
hx-on*handle events with inline scripts on elements
hx-push-urlpush a URL into the browser location bar to create history
hx-selectselect content to swap in from a response
hx-select-oobselect content to swap in from a response, somewhere other than the target (out of band)
hx-swapcontrols how content will swap in (outerHTML, beforeend, afterend, …)
hx-swap-oobmark element to swap in from a response (out of band)
hx-partialserver-driven multi-target swap; wraps content to be swapped into one or more targets after the main swap
hx-targetspecifies the target element to be swapped
hx-triggerspecifies the event that triggers the request
hx-valsadd values to submit with the request (JSON format)

Additional Attribute Reference

All other attributes available in htmx.

AttributeDescription
hx-boostadd progressive enhancement for links and forms
hx-confirmshows a confirm() dialog before issuing a request
hx-deleteissues a DELETE to the specified URL
hx-disabledisables htmx processing for the given node and any children nodes
hx-disabled-eltadds the disabled attribute to the specified elements while a request is in flight
hx-disinheritcontrol and disable automatic attribute inheritance for child nodes
hx-encodingchanges the request encoding type
hx-extextensions to use for this element
hx-headersadds to the headers that will be submitted with the request
hx-historyprevent sensitive data being saved to the history cache
hx-history-eltthe element to snapshot and restore during history navigation
hx-includeinclude additional data in requests
hx-indicatorthe element to put the htmx-request class on during the request
hx-inheritcontrol and enable automatic attribute inheritance for child nodes if it has been disabled by default
hx-paramsfilters the parameters that will be submitted with a request
hx-patchissues a PATCH to the specified URL
hx-preservespecifies elements to keep unchanged between requests
hx-promptshows a prompt() before submitting a request
hx-putissues a PUT to the specified URL
hx-replace-urlreplace the URL in the browser location bar
hx-requestconfigures various aspects of the request
hx-synccontrol how requests made by different elements are synchronized
hx-validateforce elements to validate themselves before a request
hx-varsadds values dynamically to the parameters to submit with the request (deprecated, please use hx-vals)

CSS Class Reference

ClassDescription
htmx-addedApplied to a new piece of content before it is swapped, removed after it is settled.
htmx-indicatorA dynamically generated class that will toggle visible (opacity:1) when a htmx-request class is present
htmx-requestApplied to either the element or the element specified with hx-indicator while a request is ongoing
htmx-settlingApplied to a target after content is swapped, removed after it is settled. The duration can be modified via hx-swap.
htmx-swappingApplied to a target before any content is swapped, removed after it is swapped. The duration can be modified via hx-swap.

HTTP Header Reference

Request Headers Reference

HeaderDescription
HX-Boostedindicates that the request is via an element using hx-boost
HX-Current-URLthe current URL of the browser
HX-History-Restore-Request“true” if the request is for history restoration after a miss in the local history cache
HX-Promptthe user response to an hx-prompt