htmx 4.0 is under construction — migration guide

htmx.config.defaultFocusScroll

Scroll to the focused element after a swap

The htmx.config.defaultFocusScroll option, when set to true, causes htmx to scroll the focused element into view after each swap.

Default: false

Example

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

Useful when swapping content that moves focus to a new element and you want the user’s view to follow.

See also: htmx.config