HtmxAttributes
Definitions for htmx attributes up to 1.9.10.
Path variables
hx-get, hx-post and other request attributes can include path variables by
using the path-params extension.
Once used as a path variable, it will not be included in the request body.
jsx<button hx-post ="/api/user/{id}"hx-vals ="{'id': 1,'foo':true}"hx-ext ="path-params">...</button >// Only 'foo' will be included in the request body
jsx<button hx-post ="/api/user/{id}"hx-vals ="{'id': 1,'foo':true}"hx-ext ="path-params">...</button >// Only 'foo' will be included in the request body
Extends
HxOnMap
Core
hx-boost?
optionalhx-boost:BoolStr
Add or remove progressive enhancement for links and forms.
See
https://htmx.org/attributes/hx-boost/
Source
hx-get?
optionalhx-get:string
Issues a GET to the specified URL.
See
https://htmx.org/attributes/hx-get/
Source
hx-on-?
optionalhx-on-:string
Alternative syntax for hx-on:.
All colons in event handlers can be replaced with a dash, i.e.
hx-on:click becomes hx-on-click, hx-on::before-request becomes hx-on--before-request and so on.
See
https://htmx.org/attributes/hx-on/
Since
1.9.10
Source
hx-on:?
optionalhx-on::string
Handle any event with a script inline.
See
https://htmx.org/attributes/hx-on/
Remarks
Event listeners on htmx-specific events need to be specified with a spread attribute, and
are otherwise not supported in vanilla JSX.
Alternatively, use the hx-on- all-dash syntax. (since 1.9.10)
jsx<div {...{'hx-on::before-request': '...'}} />
jsx<div {...{'hx-on::before-request': '...'}} />
Since
1.9.3
Source
hx-post?
optionalhx-post:string
Issues a POST to the specified URL.
See
https://htmx.org/attributes/hx-post/
Source
hx-push-url?
Pushes the URL into the browser location bar, creating a new history entry.
See
https://htmx.org/attributes/hx-push-url/
Source
hx-select?
optionalhx-select:string
CSS selector for content to swap in from a response.
See
https://htmx.org/attributes/hx-select/
Source
hx-select-oob?
optionalhx-select-oob:string
CSS selector for content to swap in from a response, out of band (somewhere other than the target).
See
https://htmx.org/attributes/hx-select-oob/
Source
hx-swap?
Controls how content is swapped in (outerHTML, beforeend, afterend, …).
Default
tshtmx.config.defaultSwapStyle // 'innerHTML'
tshtmx.config.defaultSwapStyle // 'innerHTML'
See
- https://htmx.org/attributes/hx-swap/
InsertPositionwhich is used inElement.insertAdjacentHTML.
Remarks
morphis observed by theidiomorphextension.
Also seealpine-morph.morphdomswaps are observed by themorphdom-swapextension.multi:swaps are observed by themulti-swapextension.
Since
1.9.6: hx-swap can be specified without any swap style.
Source
hx-target?
Specifies the target element to be swapped.
Accepts a CSS selector, optionally preceded by a modifier.
See
https://htmx.org/attributes/hx-target/
Source
hx-trigger?
optionalhx-trigger:"path-deps"|"restored"|HxTriggers|AnyStr|"every "|HxTriggerModifier|"sse:"
Specifies the event that triggers the request.
Accepts names of standard DOM events, or htmx-specific events. Optionally followed by a modifier.
See
https://htmx.org/attributes/hx-trigger/