Shopify Liquid fix

Before and after

Broken — before
{%- comment -%} sections/header.liquid (Broken icon-only search button) {%- endcomment -%}
<button type="button" class="header__icon header__icon--search" data-open-search>
  {%- render 'icon-search' -%}
</button>
Fixed — after
{%- comment -%} sections/header.liquid (Fixed with localized aria-label + decorative icon) {%- endcomment -%}
<button
  type="button"
  class="header__icon header__icon--search"
  aria-label="{{ 'general.search.search' | t | escape }}"
  aria-controls="SearchDrawer-{{ section.id }}"
  aria-expanded="false"
  data-open-search
>
  <span aria-hidden="true">{%- render 'icon-search' -%}</span>
</button>
Live preview

Fixed vs. broken example

Passes button-name
Accessibility tree: role="button", accessible name="Open site search" (decorative SVG hidden with aria-hidden="true")

Tab to each button and inspect the Accessibility pane in DevTools: the broken control exposes an empty Name while the fixed control exposes "Open site search".

Automated test

Playwright + axe-core check

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

test("Shopify header & cart icon buttons expose discernible names", async ({ page }) => {
  await page.goto("/");
  await expect(page.getByRole("button", { name: /search/i })).toBeVisible();
  const results = await new AxeBuilder({ page })
    .withRules(["button-name"])
    .analyze();
  expect(results.violations).toEqual([]);
});

Template deduplication tip

An unlabeled search or cart icon in sections/header.liquid fires on 100% of your store's URLs. A11yDrift maps every page's header violation into one global layout cluster—fix sections/header.liquid once to eliminate hundreds of raw alerts.

Screen readers

What NVDA and VoiceOver announce

Blind screen-reader users and voice-dictation users (Dragon, Voice Control) encounter unlabeled icon buttons as generic 'button' controls with no clue whether activating them opens search, closes a modal, or deletes an item.

NVDA (Windows)

Broken

"button" (silence — no action name announced)


Fixed

"Open site search, button"

VoiceOver (macOS / iOS)

Broken

"button" (unlabeled interactive element)


Fixed

"Open site search, button"

Common questions

Should I use aria-label or Shopify's visually-hidden span inside Liquid buttons?
Both expose a valid accessible name to screen readers and pass axe-core button-name. Using a localized {{ 'key' | t }} string ensures multi-language Shopify Markets storefronts announce the button in the shopper's active locale.
Why do Shopify carousel arrows and modal X buttons fail button-name so often?
Custom theme sections and third-party review/upsell apps frequently render bare <button><svg>...</svg></button> markup without text or aria-label. Audit both theme snippets and app-block embeds.
Why add aria-hidden='true' and focusable='false' to inline SVG icons?
Marking decorative icon SVGs aria-hidden='true' prevents assistive technologies from reading stray SVG paths or redundant <title> nodes while keeping the button's accessible name crisp.