โšก HTMX Dictionary

Every keyword, operator, and symbol โ€” with plain-English explanations.

HX-Redirect header
Response header: instructs the browser to navigate to a new URL.
w.Header().Set("HX-Redirect", "/login")
HX-Refresh header
Response header: tells HTMX to do a full page refresh.
w.Header().Set("HX-Refresh", "true")
afterbegin swap
Inserts the response HTML at the start of the target's children.
hx-swap="afterbegin"
afterend swap
Inserts the response HTML after the target element.
hx-swap="afterend"
beforebegin swap
Inserts the response HTML before the target element.
hx-swap="beforebegin"
beforeend swap
Inserts the response HTML at the end of the target's children.
hx-swap="beforeend"
htmx-indicator class
Add this class to elements you want shown only during a request (via hx-indicator).
<span class="htmx-indicator">Loading...</span>
hx-delete attribute
Makes a DELETE request to the given URL when triggered.
<button hx-delete="/item/1">Delete</button>
hx-disable attribute
Disables HTMX processing on the element and its children.
<div hx-disable>...</div>
hx-ext attribute
Enables HTMX extensions on the element.
<div hx-ext="json-enc">...</div>
hx-headers attribute
Adds custom HTTP headers to the request.
<div hx-get="/secure" hx-headers='{"X-Token":"abc"}'>
hx-indicator attribute
Points to an element to show while the request is in flight.
<button hx-get="/slow" hx-indicator="#spin">Load</button>
hx-on attribute
Attaches an inline event handler to HTMX lifecycle events.
<div hx-on:htmx:afterSwap="doSomething()">
hx-patch attribute
Makes a PATCH request to the given URL when triggered.
<button hx-patch="/item/1">Patch</button>
hx-push-url attribute
Pushes the request URL into the browser history after a successful response.
<a hx-get="/page" hx-push-url="true">Page</a>
hx-put attribute
Makes a PUT request to the given URL when triggered.
<button hx-put="/item/1">Update</button>
hx-select attribute
Selects a subset of the server response HTML to swap in.
<div hx-get="/page" hx-select="#content">...</div>
hx-sync attribute
Controls how concurrent requests from the same element are handled.
<input hx-get="/search" hx-sync="closest form:abort">
hx-vals attribute
Adds extra values to the request as JSON.
<button hx-post="/do" hx-vals='{"key":"val"}'>Go</button>
innerHTML swap
Default swap: replaces the inner HTML of the target element.
hx-swap="innerHTML"
none swap
No DOM swap โ€” useful when you only want a server side-effect.
hx-swap="none"
outerHTML swap
Replaces the entire target element including its tag.
hx-swap="outerHTML"
hx-get attribute
HTTP GET request to URL when triggered.
<button hx-get="/data">Load</button>
hx-post attribute
HTTP POST request to URL when triggered.
<form hx-post="/submit">
hx-trigger attribute
What event triggers the request.
hx-trigger="keyup changed delay:300ms"
hx-target attribute
CSS selector of element where response goes.
hx-target="#result"
hx-swap attribute
How response HTML is inserted.
hx-swap="outerHTML"
hx-trigger:click TRIGGER
Triggers on a click event.
hx-trigger="click" on a button
click TRIGGER
Triggers an event when the element is clicked.
<button hx-trigger="click" hx-swap="outerHTML" hx-get="/api/data">Click Me</button>
hx-confirm attribute
Shows confirm dialog before request.
hx-confirm="Are you sure?"
hx-trigger:submit TRIGGER
Triggers on a form submission.
hx-trigger="submit" on a form
hx-boost attribute
Upgrades links/forms to use HTMX.
<div hx-boost="true">
hx-trigger:change TRIGGER
Triggers on a change event.
hx-trigger="change" on an input
submit TRIGGER
Triggers an event when the form is submitted.
<form hx-trigger="submit" hx-swap="outerHTML" hx-post="/api/data">...</form>
change TRIGGER
Triggers an event when the value of the element changes.
<input type="text" hx-trigger="change" hx-swap="outerHTML" hx-get="/api/data">
hx-include attribute
Includes other element values in request.
hx-include="#extra"
hx-trigger:keyup TRIGGER
Triggers on a keyup event.
hx-trigger="keyup" on an input
HX-Request header
Request header sent by HTMX.
r.Header.Get("HX-Request")
hx-trigger:keydown TRIGGER
Triggers on a keydown event.
hx-trigger="keydown" on an input
keyup TRIGGER
Triggers an event when a key is released after being pressed.
<input type="text" hx-trigger="keyup" hx-swap="outerHTML" hx-get="/api/data">
HX-Trigger header
Response header to trigger client events.
w.Header().Set("HX-Trigger","ev")
hx-trigger:focus TRIGGER
Triggers on a focus event.
hx-trigger="focus" on an input
keydown TRIGGER
Triggers an event when a key is pressed.
<input type="text" hx-trigger="keydown" hx-swap="outerHTML" hx-get="/api/data">
focus TRIGGER
Triggers an event when the element gains focus.
<input type="text" hx-trigger="focus" hx-swap="outerHTML" hx-get="/api/data">
hx-trigger:blur TRIGGER
Triggers on a blur event.
hx-trigger="blur" on an input
blur TRIGGER
Triggers an event when the element loses focus.
<input type="text" hx-trigger="blur" hx-swap="outerHTML" hx-get="/api/data">
hx-trigger:load TRIGGER
Triggers on a load event.
hx-trigger="load" on a div
hx-trigger:revealed TRIGGER
Triggers on an intersection event.
hx-trigger="revealed" on a div
load TRIGGER
Triggers an event when the document or an element is fully loaded.
<div hx-trigger="load" hx-swap="outerHTML" hx-get="/api/data">Loading...</div>
hx-trigger:intersect every:1000s TRIGGER
Triggers on an intersection event every 1000 seconds.
hx-trigger="intersect every:1000s" on a div
revealed TRIGGER
Triggers an event when an element is revealed (e.g., shown in the viewport).
<div hx-trigger="revealed" hx-swap="outerHTML" hx-get="/api/data">Revealed</div>
hx-trigger:from:selector TRIGGER
Triggers on an element that matches the selector.
hx-trigger="from:input[type='text']" on a div
intersect TRIGGER
Triggers an event when an element intersects the viewport.
<div hx-trigger="intersect" hx-swap="outerHTML" hx-get="/api/data">Intersect</div>
every:Ns TRIGGER
Triggers an event every N milliseconds.
<div hx-trigger="every:1000" hx-swap="outerHTML" hx-get="/api/data">Every 1s</div>
hx-trigger:target:selector TRIGGER
Triggers on a target element that matches the selector.
hx-trigger="target:input[type='text']" on a div
from:selector TRIGGER
Triggers an event based on a selector.
<div hx-trigger="from:#myform" hx-swap="outerHTML" hx-get="/api/data">From Selector</div>
hx-trigger:consume queue:first TRIGGER
Triggers on the first element in the queue.
hx-trigger="consume queue:first" on a div
hx-trigger:consume queue:last TRIGGER
Triggers on the last element in the queue.
hx-trigger="consume queue:last" on a div
target:selector TRIGGER
Targets the event to a specific selector.
<div hx-trigger="target:#result" hx-swap="outerHTML" hx-get="/api/data">Target Selector</div>
consume TRIGGER
Determines how the event is handled (queue/none).
<button hx-trigger="click" hx-consume="queue" hx-swap="outerHTML" hx-get="/api/data">Consume Queue</button>
hx-trigger:consume queue:all TRIGGER
Triggers on all elements in the queue.
hx-trigger="consume queue:all" on a div
hx-trigger:consume queue:none TRIGGER
Triggers on no elements in the queue.
hx-trigger="consume queue:none" on a div
queue:first TRIGGER
Queues the request and processes the first in the queue first.
<button hx-trigger="click" hx-consume="queue:first" hx-swap="outerHTML" hx-get="/api/data">Queue First</button>
hx-trigger:delay:1000ms TRIGGER
Triggers after a delay of 1000 milliseconds.
hx-trigger="delay:1000ms" on a button
queue:last TRIGGER
Queues the request and processes the last in the queue first.
<button hx-trigger="click" hx-consume="queue:last" hx-swap="outerHTML" hx-get="/api/data">Queue Last</button>
hx-trigger:throttle:1000ms TRIGGER
Triggers with throttle of 1000 milliseconds.
hx-trigger="throttle:1000ms" on a button
queue:none TRIGGER
Does not queue the request, processes immediately.
<button hx-trigger="click" hx-consume="queue:none" hx-swap="outerHTML" hx-get="/api/data">Queue None</button>
delay:ms TRIGGER
Delays the execution of the event handler by the specified number of milliseconds.
<button hx-trigger="click" hx-delay="2000" hx-swap="outerHTML" hx-get="/api/data">Delay 2s</button>
hx-trigger:once TRIGGER
Triggers only once.
hx-trigger="once" on a button
hx-trigger:filter[cond] TRIGGER
Triggers with a filter condition.
hx-trigger="filter[cond] on a button
throttle:ms TRIGGER
Debounces the event handler execution to avoid excessive calls within the specified time.
<input type="text" hx-trigger="keyup" hx-throttle="500" hx-swap="outerHTML" hx-get="/api/data">
hx-target:css-selector TARGET
Sets the target element using a CSS selector.
hx-target="#my-target" on a div
once TRIGGER
Executes the event handler only once, even if the trigger is fired multiple times within the specified time.
<input type="text" hx-trigger="keyup" hx-once="2000" hx-swap="outerHTML" hx-get="/api/data">
filter[cond] TRIGGER
Filters the event based on a condition.
<button hx-trigger="click" hx-filter="data:ok" hx-swap="outerHTML" hx-get="/api/data">Filter Condition</button>
hx-target:closest:sel TARGET
Sets the target element to the closest match of the selector.
hx-target="closest:input[type='text']" on a div
hx-target:find:sel TARGET
Sets the target element to the first match of the selector within the current element.
hx-target="find:input[type='text']" on a div
closest:sel TARGET
Targets the closest ancestor element matching the selector.
<div hx-target="closest:#mydiv" hx-swap="outerHTML" hx-get="/api/data">Closest Selector</div>
hx-target:next:sel TARGET
Sets the target element to the next sibling matching the selector.
hx-target="next:input[type='text']" on a div
find:sel TARGET
Finds the first element matching the selector within the target element.
<div hx-target="find:#mydiv" hx-swap="outerHTML" hx-get="/api/data">Find Selector</div>
hx-target:previous:sel TARGET
Sets the target element to the previous sibling matching the selector.
hx-target="previous:input[type='text']" on a div
hx-target:this TARGET
Sets the target element to the current element.
hx-target="this" on a div
next:sel TARGET
Targets the next sibling element matching the selector.
<div hx-target="next:#mydiv" hx-swap="outerHTML" hx-get="/api/data">Next Selector</div>
hx-swap:innerHTML SWAP
Replaces the innerHTML of the target element.
hx-swap="innerHTML" on a div
previous:sel TARGET
Targets the previous sibling element matching the selector.
<div hx-target="previous:#mydiv" hx-swap="outerHTML" hx-get="/api/data">Previous Selector</div>
hx-swap:outerHTML SWAP
Replaces the outerHTML of the target element.
hx-swap="outerHTML" on a div
this TARGET
Targets the current element.
<button hx-get="/api/data" hx-swap="outerHTML" hx-target="this">Get Data</button>
hx-swap:beforebegin SWAP
Inserts content before the target element.
hx-swap="beforebegin" on a div
hx-swap:afterbegin SWAP
Inserts content after the target element.
hx-swap="afterbegin" on a div
hx-swap:beforeend SWAP
Inserts content before the target element's end.
hx-swap="beforeend" on a div
hx-swap:afterend SWAP
Inserts content after the target element's end.
hx-swap="afterend" on a div
hx-swap:delete SWAP
Removes the target element and its content.
hx-swap="delete" on a div
hx-swap:none SWAP
Does nothing, no swap occurs.
hx-swap="none" on a div
hx-swap:swap:1000ms SWAP
Replaces the target element with a delay of 1000 milliseconds.
hx-swap="swap:1000ms" on a div
queue SWAP
Queues the swap action and processes the first in the queue first.
<div hx-get="/api/data" hx-swap="queue">Swap Queue</div>
hx-swap:settle:1000ms SWAP
Settles the swap after a delay of 1000 milliseconds.
hx-swap="settle:1000ms" on a div
hx-swap:transition:true SWAP
Applies a CSS transition to the swap.
hx-swap="transition:true" on a div
remove SWAP
Removes the target element and its contents.
<div hx-get="/api/data" hx-swap="remove">Swap Remove</div>
hx-swap:scroll:top SWAP
Scrolls the target element to the top after the swap.
hx-swap="scroll:top" on a div
text SWAP
Replaces the text content of the target element with the response.
<div hx-get="/api/data" hx-swap="text">Swap Text</div>
hx-swap:scroll:bottom SWAP
Scrolls the target element to the bottom after the swap.
hx-swap="scroll:bottom" on a div
insertbefore SWAP
Inserts the response before the target element.
<div hx-get="/api/data" hx-swap="insertbefore">Swap InsertBefore</div>
hx-swap:focus-scroll:false SWAP
Does not focus the target element after the swap.
hx-swap="focus-scroll:false" on a div
insertafter SWAP
Inserts the response after the target element.
<div hx-get="/api/data" hx-swap="insertafter">Swap InsertAfter</div>
empty SWAP
Removes all child nodes of the target element.
<div hx-get="/api/data" hx-swap="empty">Swap Empty</div>
hx-include:name REQUEST CONTROL
Includes a variable in the request body.
hx-include="name" on a form
append SWAP
Appends the response to the target element.
<div hx-get="/api/data" hx-swap="append">Swap Append</div>
hx-params:name REQUEST CONTROL
Adds a parameter to the request URL.
hx-params="name=John" on a form
hx-params:[] REQUEST CONTROL
Adds an array of parameters to the request URL.
hx-params="[1,2,3]" on a form
prepend SWAP
Prepends the response to the target element.
<div hx-get="/api/data" hx-swap="prepend">Swap Prepend</div>
hx-params:[]:1 REQUEST CONTROL
Adds an indexed parameter to the request URL.
hx-params="[1,2,3]:1" on a form
hx-params:[]:1:1 REQUEST CONTROL
Adds a nested indexed parameter to the request URL.
hx-params="[1,2,3]:1:1" on a form
attr SWAP
Updates an attribute of the target element with the response.
<div hx-get="/api/data" hx-swap="attr:data-foo">Swap Attr</div>
hx-params:name[] REQUEST CONTROL
Adds an array of parameters to the request URL.
hx-params="name[]=John&name[]=Doe" on a form
class SWAP
Updates the class attribute of the target element with the response.
<div hx-get="/api/data" hx-swap="class">Swap Class</div>
hx-params:name[]:1 REQUEST CONTROL
Adds an indexed parameter to the request URL.
hx-params="name[1]=Doe" on a form
hx-params:name[]:1:1 REQUEST CONTROL
Adds a nested indexed parameter to the request URL.
hx-params="name[1][1]=Doe" on a form
style SWAP
Updates the style attribute of the target element with the response.
<div hx-get="/api/data" hx-swap="style">Swap Style</div>
html SWAP
Replaces the HTML content of the target element with the response.
<div hx-get="/api/data" hx-swap="html">Swap HTML</div>
hx-params:name[]:1:1:1 REQUEST CONTROL
Adds a deeply nested indexed parameter to the request URL.
hx-params="name[1][1][1]=Doe" on a form
hx-params:name[]:1:1:1:1 REQUEST CONTROL
Adds a deeply nested indexed parameter to the request URL.
hx-params="name[1][1][1][1]=Doe" on a form