# App block settings

URL: https://docs.sparklayer.io/help/platforms/shopify/app-block-settings
Applies to: Shopify

Style SparkLayer from Shopify's theme editor with CSS variables, hide retail elements from B2B customers, and add Core Script options to a Shopify theme.

> **Quick summary**
>
> - The **SparkLayer** app embed has 2 styling settings in Shopify's theme editor: **CSS variable overrides** for colours and fonts, and **CSS selectors for hidden elements** to hide parts of your theme from B2B customers.
> - Open them from **Home > Setup > Theme setup** in the SparkLayer Dashboard, or **SparkLayer Wholesale > Setup > Theme setup** in the Shopify app: click **Edit** beside the **SparkLayer** block.
> - Core Script options (`window.sparkOptions`) aren't a theme editor setting. Your developer adds them to `theme.liquid`.
> - The product blocks have their own settings, such as **Show SKU** and **Mode Table Only**, which match the tag settings in [Product display options](https://docs.sparklayer.io/help/storefront/product-display.md).

## How it works

The **SparkLayer** app embed loads the Core Script (the SparkLayer code on your storefront) for signed-in B2B customers. Retail customers and signed-out visitors don't get it, so none of the settings on this page change what they see.

As it loads, the app embed:

- Sets the Core Script options SparkLayer needs to run on your store.
- Matches SparkLayer's colours and fonts to your theme's, then applies your **CSS variable overrides** on top.
- Hides the retail prices, buy buttons and other parts of your theme B2B customers shouldn't use, plus anything in **CSS selectors for hidden elements**.

The styling and hiding are part of the automatic install. If your developer has [turned off the automatic install](https://docs.sparklayer.io/help/platforms/shopify/install.md#turn-off-the-automatic-install), the 2 styling settings do nothing on their own: see [If the automatic install is off](#if-the-automatic-install-is-off).

## Change colours and fonts in the theme editor

1. Go to **Home > Setup > Theme setup** in the SparkLayer Dashboard, or **SparkLayer Wholesale > Setup > Theme setup** in the Shopify app and click **Edit** beside the **SparkLayer** block. Shopify's theme editor opens at the app embed.
2. Under **Styling**, enter your CSS variables in **CSS variable overrides**, one per line.
3. Click **Save**, then sign in to your store as a B2B customer to check the result.

For example, to set your brand colour and fonts:

```css title="CSS variable overrides"
--b2b-brand-color: #1A4D8F;
--b2b-brand-color-hover: #133A6B;
--b2b-brand-font: Arial, sans-serif;
--b2b-brand-font-heading: Georgia, serif;
```

Each line is a variable name starting with two hyphens, a colon, the value and a semicolon. Leave out `<style>` tags, `:root {` and comments. Lines that aren't a variable are ignored, so you can paste the variables from the [recommended starting CSS](https://docs.sparklayer.io/help/storefront/customising-design.md#recommended-starting-css) without its first and last lines.

For what each variable changes, see the [CSS variable reference](https://docs.sparklayer.io/help/storefront/customising-design.md#variable-reference). The [4 brand values](https://docs.sparklayer.io/help/storefront/customising-design.md#the-four-brand-values) are enough for most stores.

**Overrides and CSS in your theme's code**

Your overrides are applied after SparkLayer matches your theme's colours and fonts, so they win over those. They're added near the top of the page body, after your theme's `<head>`, so they also win over the same variables set in `theme.liquid`. Keep each variable in one place to avoid surprises.

## Hide elements from B2B customers

On a store that sells retail and B2B, some parts of your theme, such as a retail price or a subscription widget, shouldn't show to B2B customers. SparkLayer already hides the common ones for your theme. To hide more:

1. Go to **Home > Setup > Theme setup** in the SparkLayer Dashboard, or **SparkLayer Wholesale > Setup > Theme setup** in the Shopify app and click **Edit** beside the **SparkLayer** block.
2. Under **Styling**, enter a CSS selector for each element in **CSS selectors for hidden elements**, one per line.
3. Click **Save**, then check your store as a B2B customer and as a retail customer.

```text title="CSS selectors for hidden elements"
.product__inventory
.announcement-bar
#loyalty-widget
```

A selector is how CSS finds an element: `.name` for a class, `#name` for an ID. Your browser's developer tools show an element's class and ID when you inspect it. A line that isn't a valid selector is ignored, and the other lines still apply.

To hide an element in your theme's code instead, add `data-spark="b2c-only"` to it. See [Install the widgets yourself](https://docs.sparklayer.io/help/platforms/shopify/install.md#install-the-widgets-yourself).

## Add Core Script options

Core Script options turn features on and off and change how they work, such as the [language](https://docs.sparklayer.io/help/storefront/languages-and-international.md) or where signed-in customers go from the account page. On Shopify, the app embed sets the options SparkLayer needs. Your developer adds any others in `theme.liquid`:

1. In your Shopify admin, go to **Online Store > Themes** ([open in the Shopify admin](https://admin.shopify.com/themes)), open the **…** menu on your theme and click **Edit code**. 
2. Open `layout/theme.liquid`.
3. Paste a `window.sparkOptions` block just before the closing `</head>` tag, with your options inside it.
4. Click **Save**, then check the change on your store as a B2B customer.

```html title="theme.liquid"
<script>
  window.sparkOptions = {
    accountRedirect: {
      urlRegex: /\/account/g,
      goTo: '/collections/all',
    },
  };
</script>
```

Shopify adds the app embed after your theme's `<head>` content, and the app embed combines your options with its own, so there's nothing else to add. Set all your options in this one block: a second `window.sparkOptions = {…}` in your theme replaces the first. For every option, see the [Core Script options](https://docs.sparklayer.io/developers/javascript-sdk/reference/options.md).

## Product block settings

The product blocks place SparkLayer's interfaces exactly where you want them on a page. Each block has settings in the theme editor, which match the tag settings in your theme's code. Click a block in the theme editor to see them.

| Block | Setting | Tag setting | What it does |
| --- | --- | --- | --- |
| **SparkLayer Product Page** | **Mode Table Only** | `mode-table-only` | [Shows every product as a table](https://docs.sparklayer.io/help/storefront/product-display.md#show-every-product-as-a-table), even with one variant |
| | **Mode All Variants** | `mode-all-variants` | [Shows all variants in one table](https://docs.sparklayer.io/help/storefront/product-display.md#show-all-variants-in-one-table-all-variants-mode) |
| | **Show Barcode** | `show-barcode` | [Shows the barcode](https://docs.sparklayer.io/help/storefront/product-display.md#barcode-isbn-upc-gtin) |
| | **Hide Dropdowns** | `hide-dropdown` | Hides the drop-downs for the options you list, for example `Size, Color` |
| | **Hide Columns On Mobile** | `hide-on-mobile` | Hides the table columns you list on phones, by option name or `Stock` |
| **SparkLayer Product Card** | **Show SKU** | `show-sku` | [Shows the product code](https://docs.sparklayer.io/help/storefront/product-display.md#show-the-product-code-sku) |
| | **Show Stock** | `show-stock` | [Shows stock status](https://docs.sparklayer.io/help/storefront/product-display.md#show-stock-status) |
| | **Show Barcode** | `show-barcode` | [Shows the barcode](https://docs.sparklayer.io/help/storefront/product-display.md#show-the-barcode) |
| | **Mode Quick Buy** | `mode-quick-buy` | [Shows products as table rows](https://docs.sparklayer.io/help/storefront/product-display.md#turn-on-quick-buy-mode) |
| | **Hide Dropdowns** | `hide-dropdown` | [Hides the drop-downs](https://docs.sparklayer.io/help/storefront/product-display.md#hide-variant-drop-downs) for the options you list |
| **SparkLayer Product Price** | **Exclude Price Breaks** | `exclude-price-breaks` | Leaves [quantity price breaks](https://docs.sparklayer.io/help/pricing/quantity-pricing.md) out of the price shown |
| **SparkLayer Product Matrix** | **Show Barcode** | `show-barcode` | Shows the barcode in the [product matrix](https://docs.sparklayer.io/help/storefront/interfaces/product-matrix.md) |

Every block also has a **Product** setting. On a product page or in a product grid, connect it to the page's product, so the block shows the right one. The **SparkLayer Product RRP** block has no other settings.

For the **SparkLayer Form** block, see [Embedding and styling forms](https://docs.sparklayer.io/help/forms/embedding-and-styling.md).

## If the automatic install is off

This is for developers. With `disableAutoInstall` set, the app embed still loads the Core Script, but doesn't add the interfaces, match your theme's styling or hide anything. **CSS variable overrides** and **CSS selectors for hidden elements** only apply when you call the functions that use them. The app embed's script adds the functions when it loads, so call them once the page has loaded:

```html title="theme.liquid"
<script>
  window.addEventListener('load', () => {
    if (!window.sparkShopify?.injectSparkStylingBehaviour) return; // not a B2B customer

    // Matches SparkLayer to your brand, then applies CSS variable overrides
    window.sparkShopify.injectSparkStylingBehaviour({
      '--b2b-brand-color': 'var(--color-primary)',
      '--b2b-brand-color-hover': 'var(--b2b-brand-color)',
      '--b2b-brand-font': 'var(--font-body-family)',
      '--b2b-brand-font-heading': 'var(--font-heading-family)',
    });

    // Hides these elements, plus CSS selectors for hidden elements
    window.sparkShopify.injectSparkHidingBehaviour(['.price', 'product-form']);
  });
</script>
```

Calling either function again replaces what it added before. To turn off the automatic install, see [Turn off the automatic install](https://docs.sparklayer.io/help/platforms/shopify/install.md#turn-off-the-automatic-install).

## FAQs

**I've saved my CSS variable overrides, but nothing has changed**

Check you're signed in as a B2B customer: the overrides only apply to them. Check each line starts with two hyphens and ends with a semicolon, and that the automatic install isn't turned off. Your browser's console lists each line it ignored, starting `[SparkLayer-AppBlock]`.

**Should I use CSS variable overrides or add CSS to my theme's code?**

Either works. CSS variable overrides need no code. CSS in `theme.liquid` can do more, such as style a single element, and suits a developer who already looks after your theme's code. See [Customising the design](https://docs.sparklayer.io/help/storefront/customising-design.md).

**I've switched themes. Do I need to enter my overrides again?**

Yes. App embed settings are saved with each theme, so a new theme, or a fresh copy of an updated theme, starts with them empty. Copy them across from the old theme's app embed.

**Can I set Core Script options in the theme editor?**

No. The app embed only has the 2 styling settings. Add Core Script options to `theme.liquid`: see [Add Core Script options](#core-script-options). Many options, such as checkout fields and payment methods, are also settings at **Storefront > Options** in the SparkLayer Dashboard ([open](https://app.sparklayer.io/storefront/options)), or **SparkLayer Wholesale > Storefront > Options** in the Shopify app, with no code.

## Next steps

- [Customising the design](https://docs.sparklayer.io/help/storefront/customising-design.md): The recommended CSS, dark mode and every CSS variable
- [Product display options](https://docs.sparklayer.io/help/storefront/product-display.md): What each tag setting changes on product pages and cards
- [Theme setup](https://docs.sparklayer.io/help/platforms/shopify/theme-setup.md): Check SparkLayer's blocks are on your theme
