Index of every page on this site: llms.txt
All skills
benjaminsehl avatar

/liquid-theme-a11y

@483f969
Run it yourself

Implement WCAG 2.2 accessibility patterns in Shopify Liquid themes. Covers e-commerce-specific components including product cards, carousels, cart drawers, price display, forms, filters, and modals. Use when building accessible theme components, fixing accessibility issues, or reviewing ARIA patterns in .liquid files.

Use this Skill: https://skilld.dev/gh/benjaminsehl/liquid-skills/liquid-theme-a11y

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesfocus-and-keyboard.md

≈1.2k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Focus & Keyboard Patterns

Focus Order Principles

  1. DOM order = tab order — never use positive tabindex values
  2. tabindex="0" makes non-interactive elements focusable (use sparingly)
  3. tabindex="-1" removes from tab order but allows programmatic focus
  4. Never reorder focus with CSS (order, flex-direction: row-reverse) without matching DOM order

Focus Trapping

class FocusTrap {
  #focusableSelector = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';

  trap(container) {
    const focusable = container.querySelectorAll(this.#focusableSelector);
    const first = focusable[0];
    const last = focusable[focusable.length - 1];

    container.addEventListener('keydown', (e) => {
      if (e.key !== 'Tab') return;
      if (e.shiftKey && document.activeElement === first) {
        e.preventDefault();
        last.focus();
      } else if (!e.shiftKey && document.activeElement === last) {
        e.preventDefault();
        first.focus();
      }
    });

    first?.focus();
  }
}

Focus Management Patterns

Opening a Modal/Drawer

openModal(trigger) {
  this.lastFocusedElement = trigger; // Save return target
  this.dialog.showModal();
  const firstFocusable = this.dialog.querySelector(
    'button, [href], input:not([disabled]), select, textarea, [tabindex]:not([tabindex="-1"])'
  );
  firstFocusable?.focus();
}

closeModal() {
  this.dialog.close();
  this.lastFocusedElement?.focus(); // Return focus
}

Dynamic Content Updates

When content is loaded dynamically (AJAX filtering, infinite scroll):

async loadContent(url) {
  const response = await fetch(url);
  const html = await response.text();
  this.container.innerHTML = html;

  // Announce to screen readers
  this.liveRegion.textContent = `${resultCount} results loaded`;

  // Move focus to results (not back to filter)
  const firstResult = this.container.querySelector('.result-item');
  firstResult?.focus();
}

Removing an Item

When an item is removed from a list (cart items, wishlist):

removeItem(item) {
  const nextItem = item.nextElementSibling || item.previousElementSibling;
  item.remove();

  if (nextItem) {
    nextItem.querySelector('button, a')?.focus();
  } else {
    // List is empty — focus the empty state or heading
    this.emptyMessage?.focus();
  }
}

Keyboard Shortcuts by Component

Tab List

Key Action
Left/Right Arrow Move between tabs
Home First tab
End Last tab
Enter/Space Activate tab

Carousel

Key Action
Left/Right Arrow Previous/next slide
Enter/Space Pause/resume auto-rotation

Combobox

Key Action
Down Arrow Open listbox / next option
Up Arrow Previous option
Enter Select current option
Escape Close listbox

Modal/Dialog

Key Action
Escape Close
Tab Cycle through focusable elements (trapped)
Shift+Tab Reverse cycle

Dropdown Menu

Key Action
Enter/Space Open submenu
Escape Close submenu
Arrow keys Navigate items

Roving Tabindex Pattern

For widget groups where only one item should be in tab order:

class TabList {
  #tabs;
  #activeIndex = 0;

  handleKeydown(event) {
    const { key } = event;
    let newIndex = this.#activeIndex;

    if (key === 'ArrowRight') newIndex++;
    else if (key === 'ArrowLeft') newIndex--;
    else if (key === 'Home') newIndex = 0;
    else if (key === 'End') newIndex = this.#tabs.length - 1;
    else return;

    event.preventDefault();

    // Wrap around
    newIndex = (newIndex + this.#tabs.length) % this.#tabs.length;

    // Update tabindex
    this.#tabs[this.#activeIndex].tabIndex = -1;
    this.#tabs[newIndex].tabIndex = 0;
    this.#tabs[newIndex].focus();

    this.#activeIndex = newIndex;
  }
}

Use for: tab lists, radio groups, toolbars, menu bars.

Screen Reader Announcements

Pattern: Live Region Update

announce(message) {
  // Use existing live region
  const region = document.querySelector('[aria-live="polite"]');
  if (!region) return;

  // Clear and re-set to trigger announcement
  region.textContent = '';
  requestAnimationFrame(() => {
    region.textContent = message;
  });
}

When to Announce

Event Urgency Method
Cart item added Polite aria-live="polite"
Form error Assertive role="alert"
Filter results count Polite aria-live="polite" + aria-atomic="true"
Page loaded (SPA) Polite Update <title> + announce
Countdown timer Polite Update every 30s, not every second

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo5 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    This skill provides a comprehensive guide for implementing WCAG 2.2 accessibility patterns in Shopify Liquid themes. It contains no executable code or external dependencies and presents no security risks.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

  • Runlayer9mo

    3 files scanned · No issues

  • ZeroLeaks7mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 483f969. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 weeks ago.

Steadyupdated 9 months ago
  • shopify
  • liquid
  • wcag
  • accessibility
  • a11y
  • e-commerce
  • aria
  • keyboard-navigation
  • screen-reader
  • focus-management

README badge

README badge for benjaminsehl/liquid-skills/liquid-theme-a11y

Implements WCAG 2.2 accessibility patterns for Shopify Liquid themes, covering product cards, carousels, modals, forms, filters, and price displays with semantic HTML and ARIA rules. Use when building or auditing Liquid components for keyboard navigation, screen reader support, and reduced-motion compliance.

Generated from the current SKILL.md.

Does this skill cover all Shopify Liquid components?
It covers e-commerce-specific components: product cards, carousels, cart drawers, price display, forms, filters, modals, tabs, dropdown navigation, and tooltips. It also includes page structure, focus management, and motion/animation patterns.
What accessibility standard does this follow?
The skill implements WCAG 2.2 patterns and is based on keyboard-only navigation, screen reader compatibility, and respect for reduced-motion preferences.
Do I need to add ARIA to every component?
No. The skill prioritizes semantic HTML first and adds ARIA only when native semantics are insufficient—for example, native `<details>/<summary>` needs no ARIA, but carousels require `role` attributes.
Does this include focus trapping for modals?
Yes. The skill describes focus trapping for modals and drawers, including how to query focusable elements and return focus to the trigger on close.
Are there code examples I can copy into my theme?
Yes. The skill provides complete HTML/Liquid templates for each component pattern, including proper ARIA attributes, form handling, and carousel implementations.

Generated from the current SKILL.md. These answers refresh after source changes.