CSS Variables

Cornerstone introduces a new way of handling styles made possible through CSS custom properties.

CSS custom properties are supported in all modern browsers so they create a simple clean way to connect your theme settings directly with your stylesheets.

In the past we were required to serve scss.liquid files to accomplish what we can now pull off in normal css. With our new approach we define all of our CSS variables in a snippet called css-variables.liquid which is included in the of the theme.liquid file.

In this file we define all our custom variables

  :root {
    --color-primary: {{ settings.color_primary }};
    --color-offset: #faf9f7;
    --font-default: {{ settings.font_family }};
    --font-heading: {{ settings.heading_font_family }};
  }

this creates a CSS custom property which is tied to the value from the theme editor. We can access these variables in our .scss files:

background: var(--color-offset);

Last updated