Cardinal docs/Advanced
Custom CSS
Where to put your own styles and code so they survive a theme update.
Cardinal is designed so you rarely need custom CSS. When you do, put it in one of the places below rather than editing a stylesheet — these live in your theme settings and template data, which are the easiest things to carry into a new version.
The three places
Use the theme's own variables
Cardinal exposes its design decisions as CSS custom properties. Writing against them means your change follows your color scheme, your theme style and your settings instead of fighting them.
/* Follows whichever color scheme the section is using */
.my-callout {
background: var(--color-background);
color: var(--color-foreground);
border: 1px solid var(--color-border);
border-radius: var(--card-radius);
padding: var(--spacing-6);
}
/* A faint tint of the scheme's text color */
.my-panel { background: rgb(var(--color-foreground-rgb) / 0.06); }
/* Use the theme's spacing scale rather than arbitrary pixels */
.my-tight-section { padding-block: var(--spacing-8); }
/* And its type scale, so it stays fluid */
.my-big-number { font-size: var(--font-size-heading-xl); }Two rules worth keeping
- 01Avoid `!important`. If a rule is not applying, the selector is usually the problem.
!importantwins today and blocks you tomorrow. - 02Respect reduced motion. The theme already cuts every transition and animation short for people who have asked their system to reduce motion, yours included — but wrapping your own animation makes the intent explicit, and keeps it right if you move the code elsewhere.
@media (prefers-reduced-motion: no-preference) {
.my-thing { transition: transform var(--transition-base); }
}Custom Liquid
For markup rather than styles — a snippet an app asks you to paste, an embed, a one-off message built from Liquid — use Custom Liquid instead of editing a theme file. It comes in two forms:
- A section, available in Add section on every template. See Custom Liquid.
- A block, available wherever the theme accepts app blocks: the product information column, Featured product, Rich text, Image with text, Banner, slideshow slides, Collage scroll, the footer, and any Custom section or group.
If you do edit the code
Keep a written list of every file you change and why. It is the difference between a ten-minute update and a lost afternoon. See Updating the theme.
Still stuck? Contact support and we will help.