Theme editor preview inspector best practices
The theme editor preview inspector allows you to navigate sections and blocks directly in the preview, and makes finding corresponding settings more intuitive.
The theme editor preview inspector draws outlines around sections and blocks to differentiate them. However, the preview inspector relies on coordinates returned by the browser's Element.getBoundingClientRect()
method to draw these outlines, which can highlight aspects of a theme's foundation that aren't normally visible.
Consider the following design guidelines to ensure that the outline of the section or block displays properly in the preview inspector:
Anchor to Avoid using negative marginsAvoid using negative margins
You should avoid using negative margins to position blocks inside a section because the blocks can show outside of the section outline.

Anchor to Avoid using padding for block spacingAvoid using padding for block spacing
To add space between blocks, you should use margin
or gap
, instead of padding
. If you use padding
, then the block outline might not display as expected.

To hide an element, you should remove it from the DOM or use display: none
, instead of visually hiding it. Visually hiding an element might result in an element outline with no element to interact with.

Anchor to Disable fixed-position elementsDisable fixed-position elements
You should disable fixed-position elements, such as sticky headers, when the preview inspector is enabled. Leaving these elements enabled can lead to a confusing experience.
To learn more about detecting the theme editor preview inspector, refer to Integrate sections with the theme editor.

Anchor to Section and block duplicationSection and block duplication
If you need to duplicate a section or block, then you should ensure that the element that you want the theme editor to recognize is the only one that includes a data-shopify-editor
attribute. The theme editor relies on the data-shopify-editor
attributes to identify sections and blocks, so duplicating them can lead to conflicts in identifying the correct element.
Sections use the data-shopify-editor-section
attribute, and blocks use the data-shopify-editor-blocks
attribute.