Skip to main content
tc

HTMX

Loading states, error handling, polling, OOB swaps.

# HTMX LoadingIndicator

Global HTMX loading overlay (shows during any htmx request — try any button below):

Loading…

# HTMX InlineLoadingOverlay

Per-target loading indicator (shown via hx-indicator):

Loading…

# HTMX LoadingButton

Click — the button swaps to its loading state during the request:

# HTMX ConfirmDelete

Deletes the item below via HTMX after a confirmation dialog:

item-123

Delete me — the row is replaced by the server response.

# HTMX CSRFToken

Renders a hidden CSRF input field:

# HTMX SwapOOB

Out-of-band swap element (processed by HTMX after a response):

target: current value

# HTMX GlobalErrorHandling

Wires up htmx:responseError and htmx:beforeOnError events:

# HTMX ViewTransitions

Enables native View Transitions on HTMX swaps — pages cross-fade instead of hard-cutting, with graceful degradation in browsers without support.

Go
htmx.ViewTransitions(htmx.ViewTransitionsProps{Global: true, Nonce: nonce})

# HTMX PolledRegion

Auto-refreshing region polling /api/demo-stats every 5s (stops after 3 ticks):

Requests served: 48210

Updated 03:10:30 UTC

auto-refreshing