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?
optional
hx-boost:BoolStr
Add or remove progressive enhancement for links and forms.
See
https://htmx.org/attributes/hx-boost/
Source
hx-get?
optional
hx-get:string
Issues a GET
to the specified URL.
See
https://htmx.org/attributes/hx-get/
Source
hx-on-?
optional
hx-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:?
optional
hx-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?
optional
hx-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?
optional
hx-select:string
CSS selector for content to swap in from a response.
See
https://htmx.org/attributes/hx-select/
Source
hx-select-oob?
optional
hx-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
ts
htmx.config.defaultSwapStyle // 'innerHTML'
ts
htmx.config.defaultSwapStyle // 'innerHTML'
See
- https://htmx.org/attributes/hx-swap/
InsertPosition
which is used inElement.insertAdjacentHTML
.
Remarks
morph
is observed by theidiomorph
extension.
Also seealpine-morph
.morphdom
swaps are observed by themorphdom-swap
extension.multi:
swaps are observed by themulti-swap
extension.
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?
optional
hx-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/