Skip to content
shopdepot.dev

Themes

Platform pages and components

Brand tokens, the logo, the contact form, the cart summary, and the checkout and account pages your theme styles but does not build.

View as Markdown

Some pages and components in a store belong to the platform: checkout, customer accounts, returns, the review form, the contact form and the cart summary. They behave the same in every store. Your theme makes them look like the store through two contracts - brand tokens for whole pages, and stable class names for components inside your pages.

Brand tokens

snippets/brand-tokens.twig is a contract with the platform. Your layout renders it in <head>, and so do the platform's own pages on the store domain - the account, order status, returns and complaints - so they take the store's colours, radius and fonts from your theme without a second set of settings.

{# snippets/brand-tokens.twig #}
{% set s = settings %}
<style>
  @font-face { font-family: "Example Sans"; font-weight: 100 900; font-display: swap;
    src: url("{{ 'fonts/example-sans.woff2'|asset_url }}") format("woff2"); }
  :root {
    --color-bg: {{ s.color_background|default('#ffffff') }};
    --color-surface: {{ s.color_surface|default('#f2f2f2') }};
    --color-ink: {{ s.color_text|default('#111111') }};
    --color-accent: {{ s.color_accent|default('#111111') }};
    --color-accent-ink: {{ s.color_accent_ink|default('#ffffff') }};
    --radius: {{ s.radius|default(8) }}px;
    --base-size: {{ s.base_size|default(16) }}px;
    --heading-weight: {{ s.heading_weight|default('600') }};
    --font-body: "Example Sans", system-ui, sans-serif;
  }
</style>
Token Required Meaning
--color-bg yes Page background.
--color-surface yes Cards, fields, boxes on the background.
--color-ink yes Text.
--color-accent yes Buttons and links.
--color-accent-ink yes Text on the accent.
--radius yes Corner radius of buttons, fields and cards.
--base-size yes Base font size.
--heading-weight yes Weight of headings.
--font-body yes Body font stack.
--font-display Headings font stack.
--font-mono Monospace font stack.
--radius-pill Radius of pill buttons.
--button-transform uppercase or none for button labels.

Rules of the contract:

  • The file name is fixed: snippets/brand-tokens.twig.
  • Output only custom properties on :root, plus what the fonts need (@font-face, a <link> to a font file). No rules for elements - the platform pages have their own layout and components, and a button { … } in this snippet would break them.
  • The platform never reads your settings by name - every theme names them differently. It reads the tokens.

The core sections and blocks style themselves with the same tokens, which is why they fit any theme. Use them in your own CSS too.

Platform pages show the store logo from your theme: the logo setting (and logo_width) when the merchant uploaded one, otherwise assets/img/logo.svg from your package. Ship a sensible logo.svg.

The contact form

The contact form is a platform component. Your contact page or section places it, and the platform draws the fields, consents, validation, spam protection and sending:

{{ form('contact') }}

Which fields are shown and required, the subject list and the consents are set by the merchant in the store settings. You style the form with these classes - they are a contract and do not change:

Class Element
sd-form The form.
sd-form__field, sd-form__field--<name> A field wrapper, with a modifier per field.
sd-form__label, sd-form__req Label and the required marker.
sd-form__input, sd-form__textarea, sd-form__select, sd-form__file Controls.
sd-form__error A field error.
sd-form__consents, sd-form__consent, sd-form__check, sd-form__box, sd-form__consent-text Consents.
sd-form__submit The button.
sd-form__message[data-state] The result message - data-state is ok or error.
sd-form__reference The message reference number after sending.

The default styles use :where(), so any rule of yours wins without !important.

Options

{{ form('contact', {
  submit: 'Send',
  classes: { field: 'field', input: 'input', button: 'btn btn--primary' },
  subject: 'Wholesale enquiry',
  phone: 'required',
  order: 'off',
  fields: [
    { name: 'company', label: 'Company', type: 'text', required: true },
    { name: 'volume', label: 'Monthly volume', type: 'select', options: ['Under 100', '100-1000', 'Over 1000'] }
  ]
}) }}
Option Description
submit The button label.
classes Your own classes added to field, label, input, textarea, select, file, error, consent, button, message.
subject A fixed subject - for a partner or wholesale form on its own page.
phone, order, message off, optional or required.
fields Up to 12 extra fields: name, label, type (text, email, tel, url, number, textarea, select, checkbox), required, placeholder, options. Their answers are added to the message.

These options are signed into the form, so a visitor cannot change them. The name, e-mail and consent fields cannot be changed by a theme.

The form sends with JavaScript in the background (POST /contact/send.js) and works without it as a normal form post.

The cart summary

On the cart page, print the platform's summary:

<aside class="cart__summary">{{ cart_summary() }}</aside>

It holds the coupon field, applied discounts and threshold hints, delivery from the cheapest method, the estimated total, the "including VAT" line when the store shows it, and the checkout button. It applies coupons in place (POST /cart/discount.js) and then fires shopdepot:cart:changed with the new cart and the fresh cart page, so you can refresh your line items. Style it with its sd-cart-summary__* classes; its content and behaviour are not themeable.

The chat widget

When the merchant turns on the chat (Customer service → Settings → Chat), the platform adds the widget to every page your theme renders, just before </body>. The theme does nothing: no snippet, no script, no styles to ship. The widget has its own styles and does not depend on your CSS. Do not put an element with id="sd-chat" in your theme. A page that has one is left alone, because the platform takes it for a widget that is already there.

Checkout and accounts

Checkout, the thank you page, customer accounts, order status, returns and complaints are rendered by the platform outside your theme. There are no theme files for them and none are read. Checkout is branded by the merchant in the store settings; the account and returns pages use your brand tokens and logo.

Link to them with url_for: url_for('account'), url_for('cart'). Checkout is reached from the cart.