Shopify Liquid fix

Before and after

Broken — before
{%- comment -%} snippets/price.liquid + assets/component-price.css (Broken) {%- endcomment -%}
<div class="price">
  <span class="price-item price-item--regular" style="color: rgba(var(--color-foreground), 0.45);">
    {{ product.compare_at_price | money }}
  </span>
  <span class="badge price__badge-sale" style="background: #34d399; color: #ffffff;">
    {{ 'products.product.on_sale' | t }}
  </span>
</div>
Fixed — after
{%- comment -%} snippets/price.liquid + assets/component-price.css (Fixed >= 4.5:1) {%- endcomment -%}
<div class="price">
  <span class="price-item price-item--regular" style="color: rgba(var(--color-foreground), 0.78);">
    <span class="visually-hidden">{{ 'products.product.price.regular_price' | t }}</span>
    {{ product.compare_at_price | money }}
  </span>
  <span class="badge price__badge-sale" style="background: #047857; color: #ffffff;">
    {{ 'products.product.on_sale' | t }}
  </span>
</div>
Live preview

Fixed vs. broken example

Passes color-contrastContrast: 7.58:1 body / 5.93:1 CTA (Passes 4.5:1 AA)
Accessibility tree: paragraph "Free shipping..." (#475569 on #ffffff = 7.58:1 PASS AAA) · button "Add to Cart" (#ffffff on #0369a1 = 5.93:1 PASS AA)

Inspect the foreground and background colors in Chrome DevTools Color Picker to verify the live WCAG AA (4.5:1 normal text, 3:1 large text) contrast badges.

Automated test

Playwright + axe-core check

tests/a11y-color-contrast.spec.ts
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";

test("Shopify product price & sale badge pass color-contrast", async ({ page }) => {
  await page.goto("/products/cobalt-ceramic-mug");
  const results = await new AxeBuilder({ page })
    .include(".product__info-wrapper")
    .withRules(["color-contrast"])
    .analyze();
  expect(results.violations).toEqual([]);
});

Template deduplication tip

A faded .price-item--regular opacity rule inside assets/component-price.css or snippets/price.liquid can generate 500+ raw violations across /products/* and /collections/*. A11yDrift groups all of them into one cluster pointing to the shared Liquid price partial.

Who this affects

Low-vision readers, older users with presbyopia, people with color-vision deficiencies, and anyone viewing a screen in bright sunlight struggle or fail to read muted gray captions, pale badges, and low-contrast CTA buttons.

NVDA & VoiceOver transcript

Screen readers announce the same copy for both versions; this rule primarily impacts low-vision readers, screen magnifiers, and visual legibility.

NVDA (Windows)

Broken

Screen readers still speak "Free shipping on orders over $75" and "Add to Cart, button", but screen magnifier and low-vision users cannot visually locate or read the faded copy and pale blue button.


Fixed

Screen readers announce "Free shipping on orders over $75" and "Add to Cart, button", while sighted low-vision and ZoomText users clearly distinguish both the 7.58:1 body copy and 5.93:1 CTA.

VoiceOver (macOS / iOS)

Broken

VoiceOver speaks "Add to Cart, button", yet users combining VoiceOver with Zoom or macOS Increase Contrast experience severe glare washout on the 2.14:1 sky-blue fill.


Fixed

VoiceOver speaks "Add to Cart, button", and the 5.93:1 darkened surface stays legible across macOS Zoom, mobile sunlight, and high-brightness displays.

Common questions

Why does Shopify Dawn fail contrast on compare-at prices and footer links?
Dawn styles muted elements with rgba(var(--color-foreground), 0.55) or 0.60, which dips below 4.5:1 against off-white backgrounds like #f3f3f3. Raising foreground alpha to at least 0.75–0.80 or setting an explicit hex token resolves the failure storewide.
Can a Shopify theme app or overlay widget fix Liquid contrast issues?
No. Automated audit crawlers and real browsers test the base rendered DOM before any optional widget toggle is clicked. Fixing the theme's color_schemes in settings_data.json and CSS variables solves the root cause permanently.
Does WCAG 2.2 AA allow lower contrast on large hero headings in Shopify sections?
Large text (at least 18pt / 24px regular, or 14pt / 18.67px bold) requires 3.0:1 instead of 4.5:1. When placing text over Shopify hero banner images, add a dark linear-gradient scrim so contrast holds across every viewport crop.