htmx 4.0 is under construction — migration guide

HX-Reselect

Override the content selection from the server

The HX-Reselect response header overrides which part of the response is used for swapping, replacing whatever hx-select was set on the triggering element.

Syntax

HX-Reselect: #content

The value is a CSS selector applied to the response HTML to extract the content to swap in.

Example

Return a full page but tell htmx to only use a specific fragment:

return Response( full_page_html, headers={'HX-Reselect': '#main-content'} )

Notes

  • Overrides hx-select on the source element
  • Evaluated after the response is received, before swapping

See also: hx-select, HX-Retarget, HX-Reswap