A new onlyMainContent() method is available in Drupal\Core\Htmx\Htmx. This method adds a data attribute which causes the HTMX request to use the drupal_htmx wrapper format paramter. When this parameter is present, Drupal only returns the main content, excluding header, footers, etc.
Return the full page with all regions and block on the page.
(new Htmx())
->post($form_url)
->select('[data-export-wrapper]')
->target('[data-export-wrapper]')
Only return the main content without any extra data from the blocks and regions around the content.
(new Htmx())
->post($form_url)
->onlyMainContent()
->select('[data-export-wrapper]')
->target('[data-export-wrapper]')
When the new method is used, a special data-hx-drupal-only-main-content data attribute will be added. When this attribute is present on an HTMX enhanced element, the query parameter for the drupal_htmx wrapper format created in #3522597: Return only main content for selected htmx requests will be added to HTMX requests prepared by Drupal.