Skip to content
← Back to Blog
Canvas Tips & Tutorials

How to Customise Canvas Template Colours With CSS Variables

Canvas Builder6 min read

Rebranding a Canvas site by hunting through thousands of lines of CSS for hex codes is slow and error-prone. Canvas exposes its core design decisions as CSS custom properties, so you can change a brand colour once and see it update across buttons, links, icons and accents.

Key Takeaways
  • The single most important variable is --cnvs-themecolor, paired with --cnvs-themecolor-rgb for any rgba() usage.
  • Header and menu colours have their own variables, so you never need to override selectors like #header for common changes.
  • Variables cascade, so you can re-theme a single section or card by redefining them on that element.
  • Always override in a block loaded after style.css rather than editing core files, so template updates do not wipe your branding.

How Canvas Theming Works

The Canvas HTML Template is built on Bootstrap 5 and bundles it, so you never load a Bootstrap CDN alongside it. Canvas then defines its own namespaced variables on top, all prefixed --cnvs-. That prefix matters. Variables such as --bs-primary or --color-primary do not drive Canvas components, so overriding them produces no visible result.

The variables you will use most often are:

Variable Controls
--cnvs-themecolor Primary brand colour: buttons, links, accents, icons
--cnvs-themecolor-rgb The same colour as R, G, B values for translucent effects
--cnvs-primary-font Body and general text font family
--cnvs-secondary-font Secondary font, often used for headings and accents
--cnvs-header-bg Header background colour
--cnvs-header-sticky-bg Header background once it becomes sticky
--cnvs-primary-menu-color Main navigation link colour
--cnvs-primary-menu-hover-color Navigation hover and active colour
--cnvs-logo-height Logo height (with a sticky counterpart, --cnvs-logo-height-sticky)
How to Customise Canvas Template Colours With CSS Variables, abstract concept illustration

Change the Theme Colour in Two Lines

The fastest win is redefining the theme colour. Add this after your style.css link in the document head, or in your own stylesheet that loads after it:

HTML
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="css/font-icons.css">

<style>
  :root {
    --cnvs-themecolor: #0f766e;
    --cnvs-themecolor-rgb: 15, 118, 110;
  }
</style>

Both lines matter. Canvas uses --cnvs-themecolor for solid fills and --cnvs-themecolor-rgb wherever it needs transparency: soft shadows, overlays and similar effects. Change only the hex value and those translucent effects keep the old colour. The mismatch is subtle, but clients notice it. Match the number format already used in your copy of style.css.

Colour choice is a design decision as much as a technical one. Check that white text on your chosen colour reaches a 4.5:1 contrast ratio, because Canvas places white text on theme-coloured buttons by default. Pale yellows and light greens usually fail that test.

Header and Menu Colours

Navigation is where brand colour is most visible. Canvas gives it dedicated variables so you can avoid fragile selector overrides:

CSS
:root {
  --cnvs-header-bg: #ffffff;
  --cnvs-header-sticky-bg: rgba(255, 255, 255, 0.96);
  --cnvs-primary-menu-color: #1f2937;
  --cnvs-primary-menu-hover-color: #0f766e;
}

A separate --cnvs-header-sticky-bg lets the header shift subtly on scroll, for example from transparent over a hero image to a solid white bar. Tying --cnvs-primary-menu-hover-color to your theme colour keeps hover states consistent with buttons and links elsewhere. If a header variable does not seem to apply, inspect the element in DevTools. Some demos set values at a more specific level, and in that case scope your override to #header instead of :root.

For the hero directly beneath the header, our guide to hero section designs that convert shows how colour choices affect click-through.

HTML template customisation, abstract technical diagram

Typography and Logo Sizing

Colour is only part of a brand. Canvas handles fonts through --cnvs-primary-font and --cnvs-secondary-font, so swapping typefaces is a variable change rather than a hunt through heading selectors:

CSS
:root {
  --cnvs-primary-font: "Inter", sans-serif;
  --cnvs-secondary-font: "Playfair Display", serif;
  --cnvs-logo-height: 48px;
  --cnvs-logo-height-sticky: 36px;
}

Load the font files before referencing them (a Google Fonts link in the head works). For logo sizing, use --cnvs-logo-height and --cnvs-logo-height-sticky rather than writing rules that target the logo image directly. Canvas calculates header spacing from these values, so a direct image override can break vertical alignment of the menu. If you are converting design specs to relative units, the px to rem converter saves manual arithmetic.

Scoped Colour Overrides for Sections and Components

CSS variables cascade, so you can redefine them on any element and every Canvas component inside it follows. This is useful for a pricing section, a campaign banner or a partner-branded block:

CSS
.section-campaign {
  --cnvs-themecolor: #be123c;
  --cnvs-themecolor-rgb: 190, 18, 60;
}
HTML
<div class="section section-campaign">
  <div class="container">
    <h2>Limited Offer</h2>
    <a href="#" class="button button-large">Claim It</a>
  </div>
</div>

The button inside inherits the crimson theme colour while the rest of the page keeps the teal brand colour. This approach also works for multi-brand sites, event microsites and seasonal promotions. It is the same principle used in a conference website build, where individual tracks or sponsors need their own accent colour.

Common Mistakes and Honest Limitations

Variables are powerful, but they do not cover everything. Know the boundaries before promising a client a one-line rebrand:

  1. Editing core files. Changing values directly in style.css works until you update the template, then your changes are overwritten. Keep overrides separate.
  2. Forgetting the RGB twin. Updating --cnvs-themecolor without --cnvs-themecolor-rgb leaves old-coloured shadows and overlays.
  3. Hard-coded colours. Some demo-specific styles and inline attributes use literal hex values. Search your page for the old brand hex after changing variables.
  4. Wrong variable names. Using Bootstrap-style names will not affect Canvas components. Stick to the --cnvs- set.
  5. Skipping contrast checks. A brand colour that looks great as a swatch can fail accessibility as a button background.

If you prefer to describe the change rather than code it, AI Edit Mode can apply colour and typography changes from a plain-language instruction, which is useful when iterating through several palettes with a client.

For teams producing many branded sites, Canvas Builder generates layouts that already follow these variable conventions, so a palette change stays a few lines of CSS instead of a manual cleanup.

Frequently Asked Questions

What is the main CSS variable for changing colours in Canvas?

The main variable is --cnvs-themecolor. It drives the primary brand colour across buttons, links and accents. Pair it with --cnvs-themecolor-rgb so translucent effects update as well.

Where should I put my Canvas colour overrides?

Place them in a :root block that loads after style.css, either in a style tag in the head or in your own stylesheet. Avoid editing style.css directly so template updates do not erase your changes.

Why is my colour change not showing on some elements?

Usually the element uses a hard-coded value, a more specific selector, or you overrode a Bootstrap variable such as --bs-primary that Canvas does not use for that component. Inspect the element in DevTools to see which declaration wins.

Can I use different theme colours on different sections?

Yes. Redefine --cnvs-themecolor and --cnvs-themecolor-rgb on a section class. Every Canvas component inside that section inherits the new values through the CSS cascade.

How do I change the logo size without breaking the header?

Set --cnvs-logo-height and --cnvs-logo-height-sticky. Do not write CSS rules that target the logo image directly, because Canvas uses these variables to keep header spacing and menu alignment correct.

If you’re working with the Canvas HTML Template and want to generate production-ready layouts faster, try Canvas Builder free and see how much time you save on every project.

Build it by describing it

Canvas Builder turns a plain-English description into a complete, responsive website in minutes, then hands you the clean Bootstrap 5 HTML to host anywhere.

Related Posts