htmx 4.0 is under construction — migration guide

htmx.config.defaultSwap

Default swap style for responses

The htmx.config.defaultSwap option sets the default swap style when hx-swap is not specified.

Default: "innerHTML"

Valid Values

  • "innerHTML" - Replace inner content
  • "outerHTML" - Replace entire element
  • "beforebegin" - Insert before element
  • "afterbegin" - Insert as first child
  • "beforeend" - Insert as last child
  • "afterend" - Insert after element
  • "delete" - Delete the target element
  • "none" - Don’t swap content

Example

htmx.config.defaultSwap = "outerHTML";
<meta name="htmx-config" content='{"defaultSwap":"outerHTML"}'>