Skip to main content

Custom sections

A new section is a new file in sections/. Shopify picks it up automatically — there is no registration step.

A minimal section


Rules

Use the design tokens

Never hard-code a colour. background: #0b1119 will not follow the merchant’s brand; var(--color-surface-container-low) will.

Use the container class

The theme has a .container class that handles the max width and the responsive gutters. Use it rather than rolling your own.

Use section.shopify_attributes

On the section root element. It is what lets the theme editor and app extensions target your section.

Use block.shopify_attributes

On every block wrapper. Same reason.

Scope your styles

Do not write bare element selectors like .container or h2 in a section’s style block. Section styles are global once rendered — they will leak into every other section on the page. Always scope to your section’s class.

Put the styles in a <style> block

The {% style %} tag is Shopify’s way of letting the theme editor move section CSS into a global stylesheet. It is the correct choice for a section.

Adding it to a template

Open the template in the theme editor and click Add section. Your new section appears in the list automatically. You do not need to edit any JSON.
If you want the section available in a template by default, you can add it to templates/*.json. But be aware that rebuilding a template from JSON can drop blocks the merchant has configured. Prefer adding sections through the editor.

Making it upgrade-safe

VARAHI’s own section files use the same conventions. If you follow them, a future theme update will not conflict with your code.

A worked example

A “Press & awards” section with a logo row.

Code reference

The token system and the file map.

Performance

The budgets your section has to fit inside.