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

/liquid-theme-standards

@483f969
Run it yourself

CSS, JavaScript, and HTML coding standards for Shopify Liquid themes. Covers BEM naming inside stylesheet tags, design tokens, CSS custom properties, Web Components for themes, defensive CSS, and progressive enhancement. Use when writing CSS/JS/HTML in .liquid files or theme asset files.

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

Nothing lands on disk. Nothing to clean up.

Fork this Skill

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

referencescss-patterns.md

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

CSS Patterns for Shopify Liquid Themes

Complete Component Example

<section
  class="featured-collection"
  style="
    --section-padding: {{ section.settings.padding | default: 60 }}px;
    --columns: {{ section.settings.columns | default: 4 }};
  "
>
  {% if section.settings.heading != blank %}
    <h2 class="featured-collection__heading">{{ section.settings.heading }}</h2>
  {% endif %}

  <div class="featured-collection__grid">
    {% for product in collection.products limit: section.settings.limit %}
      {% render 'product-card', product: product %}
    {% endfor %}
  </div>
</section>

{% stylesheet %}
  .featured-collection {
    padding-block: var(--section-padding);
    container-type: inline-size;
  }

  .featured-collection__heading {
    font-size: var(--font-size-2xl);
    margin-block-end: var(--space-lg);
    text-align: center;
  }

  .featured-collection__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-md);
  }

  @container (min-width: 768px) {
    .featured-collection__grid {
      grid-template-columns: repeat(var(--columns), 1fr);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .featured-collection * {
      transition: none !important;
    }
  }
{% endstylesheet %}

Layout Patterns

CSS Grid for Page Layouts

.section-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-lg);
}

Flexbox for Component Layouts

.product-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

Page-Width Container

.page-width {
  width: min(100%, var(--page-width));
  margin-inline: auto;
  padding-inline: var(--space-md);
}

Full-Bleed with Content Constraint

.full-bleed {
  display: grid;
  grid-template-columns: var(--space-md) 1fr var(--space-md);
}

.full-bleed > * {
  grid-column: 2;
}

.full-bleed > .full-width {
  grid-column: 1 / -1;
}

Responsive Images

.image-container {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}

.image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

Using :is() for Parent-Child Relationships

/* Multiple parents, same child */
:is(.hero, .banner) .heading {
  font-size: var(--font-size-2xl);
}

/* Same parent, multiple children */
.card:is(.card--featured, .card--promoted) {
  border: 2px solid var(--color-accent);
}

Don't use :is() for simple comma-separated selectors — use regular comma separation instead.

Variable Override Pattern

Use CSS variables to reduce redundancy across modifiers:

.button {
  background: rgb(var(--button-color) / var(--button-opacity, 1));
  color: rgb(var(--button-text));
}

.button--secondary {
  --button-color: var(--color-secondary);
  --button-text: var(--color-foreground);
}

.button--outline {
  --button-color: transparent;
  --button-text: var(--color-accent);
  --button-opacity: 0;
}

Focus Styles

:focus-visible {
  outline: 2px solid rgb(var(--color-focus));
  outline-offset: 2px;
}

/* High contrast mode */
@media (forced-colors: active) {
  :focus-visible {
    outline: 3px solid LinkText;
  }
}

Print Styles

@media print {
  .no-print,
  .cart-drawer,
  .navigation__mobile {
    display: none !important;
  }

  a[href^='http']::after {
    content: ' (' attr(href) ')';
  }

  .product-card {
    break-inside: avoid;
  }
}

Animation Patterns

/* Safe defaults — only animate transform and opacity */
.product-card {
  transition: transform 0.2s ease;
}

.product-card:hover {
  transform: translateY(-2px);
}

/* will-change only during animation */
.product-card:hover {
  will-change: transform;
}
.product-card:not(:hover) {
  will-change: auto;
}

CSS Documentation

/* =============================================================================
   Product Card
   ============================================================================= */

/**
 * Card component for displaying product information.
 *
 * @example
 * <div class="product-card product-card--featured">
 *   <div class="product-card__image">...</div>
 *   <div class="product-card__info">...</div>
 * </div>
 */
.product-card { }

Source: SKILL.md on GitHub

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

    The skill provides coding standards and best practices for Shopify Liquid themes, covering CSS, JavaScript, and HTML. It includes safe examples for using jq to edit JSON configuration files and standard Web Component patterns.

  • 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

README badge

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