Shopify

Unlocking Advanced Shopify Layouts: Mastering Custom Sections with Liquid and CSS Grid

As a Shopify migration expert at Shopping Cart Mover, I often see merchants pushing the boundaries of what their online stores can do. While Shopify's platform is incredibly robust, and its AI tools are getting smarter every day, there are moments when a truly unique vision requires a touch of custom code. This is precisely what unfolded in a recent Shopify Community forum thread that caught my eye, highlighting a common challenge: creating complex, multi-component layouts that go beyond standard theme capabilities or AI generation.

Shopify theme code editor with vip-tiers.liquid file selected
Shopify theme code editor with vip-tiers.liquid file selected

The AI Wall: When Your Vision Needs More Than a Prompt

Our story begins with Rae7, a dedicated store owner with a clear vision for a 'VIP tiers' section. Imagine a beautiful 4-column horizontal grid, each column representing a tier with its own image, a bold title, a points range subtitle, and a detailed reward description. The entire section was to sit against a unified, full-width background image, with individual tier boxes having their own distinct colors. Sounds like a fantastic way to engage customers, right?

However, Rae7 quickly discovered the limitations of relying solely on Shopify's built-in AI assistant. Despite repeated attempts, the AI struggled to generate the complete, compound layout. As Rae7 expressed, "I keep getting only part of what I have asked for…" Shopify support confirmed the challenge: "it requires custom liquid code."

This experience is not uncommon. While Shopify's AI is excellent for generating simple content or basic sections, truly intricate layouts with specific structural, styling, and dynamic content requirements often push its current capabilities to the limit. As fellow expert Moeed in the thread clarified, "So it genuinely does need a custom section built in the theme code, that part is true."

Understanding the Power of Custom Liquid Sections

Hearing "custom Liquid code" can sound intimidating, especially for new store owners managing their budget. However, it's important to understand what this means. A custom Liquid section is essentially a modular piece of code that you add directly to your Shopify theme. It allows you to define not just the HTML structure and CSS styling, but also the editable settings that appear in your theme customizer.

The beauty of a custom section is that once it's built, it becomes a reusable component within your theme. You can add it to any page, drag and drop it, and configure its content and appearance directly from the intuitive theme editor, just like any other standard section. This means it's typically a one-time development cost, not a recurring app subscription, offering long-term value and complete control over your store's design.

CSS Grid: The Layout Powerhouse for Modern Shopify Stores

Before diving into the solution, it's crucial to appreciate the underlying technology that makes such flexible layouts possible: CSS Grid. As NKCreativeSoulutions wisely pointed out in the thread, "You probably don’t need so much liquid, look at using grid in CSS."

CSS Grid Layout is a two-dimensional grid system for the web. It allows developers to create complex responsive web design layouts more easily and consistently across different screen sizes. For a layout like the VIP tiers, where you need multiple columns that adapt gracefully from desktop to mobile, CSS Grid is the ideal tool. It provides precise control over item placement, sizing, and alignment, ensuring your custom sections look pixel-perfect on any device.

A Community-Driven Solution: The VIP Tiers Section

The Shopify community truly shines when members step up to help. In this thread, ajaycodewiz provided an incredible, fully functional custom Liquid section for the VIP tiers, complete with HTML, CSS, and a comprehensive schema for theme editor settings. This generous contribution perfectly addresses Rae7's original challenge and serves as a fantastic example of how custom code can bring complex visions to life.

The provided section is designed to be highly configurable, allowing merchants to:

  • Set a main heading and its color.
  • Add a background image or color for the entire section, with an adjustable overlay.
  • Control layout aspects like content width, spacing between columns, card padding, and corner radius.
  • Define image sizes and text sizes for titles, points, and descriptions.
  • Customize each individual VIP tier card with its own image, title, points, description, background color, and text color.

Here’s the complete code provided by ajaycodewiz, ready to be implemented:

{%- liquid
  assign s = section.settings
  assign cols = section.blocks.size | at_least: 1
-%}



{%- if s.heading != blank -%}

{{ s.heading }}

{%- endif -%}
{%- for block in section.blocks -%} {%- liquid assign b = block.settings assign card_alpha = b.card_opacity | divided_by: 100.0 -%}
{%- if b.image != blank -%} {{ b.image.alt | default: b.title | escape }} {%- endif -%} {%- if b.title != blank -%}

{{ b.title }}

{%- endif -%} {%- if b.points != blank -%}

{{ b.points }}

{%- endif -%} {%- if b.description != blank -%}
{{ b.description }}
{%- endif -%}
{%- endfor -%}
{% schema %} { "name": "VIP tiers", "tag": "section", "settings": [ { "type": "text", "id": "heading", "label": "Heading", "default": "VIP tiers" }, { "type": "color", "id": "heading_color", "label": "Heading colour", "default": "#ffffff" }, { "type": "header", "content": "Background behind all tiers" }, { "type": "image_picker", "id": "bg_image", "label": "Background image" }, { "type": "color", "id": "bg_color", "label": "Background colour", "default": "#12121a" }, { "type": "color", "id": "overlay_color", "label": "Overlay colour", "default": "#000000" }, { "type": "range", "id": "overlay_opacity", "min": 0, "max": 90, "step": 5, "unit": "%", "label": "Overlay darkness", "default": 35 }, { "type": "header", "content": "Layout" }, { "type": "range", "id": "content_width", "min": 800, "max": 1800, "step": 20, "unit": "px", "label": "Content width", "default": 1200 }, { "type": "range", "id": "gap", "min": 0, "max": 60, "step": 2, "unit": "px", "label": "Space between columns", "default": 20 }, { "type": "range", "id": "card_padding", "min": 8, "max": 60, "step": 2, "unit": "px", "label": "Padding inside each column", "default": 28 }, { "type": "range", "id": "corner_radius", "min": 0, "max": 40, "step": 2, "unit": "px", "label": "Corner radius", "default": 12 }, { "type": "range", "id": "image_height", "min": 40, "max": 260, "step": 10, "unit": "px", "label": "Tier image size", "default": 120 }, { "type": "range", "id": "padding_top", "min": 0, "max": 160, "step": 4, "unit": "px", "label": "Padding top", "default": 64 }, { "type": "range", "id": "padding_bottom", "min": 0, "max": 160, "step": 4, "unit": "px", "label": "Padding bottom", "default": 64 }, { "type": "header", "content": "Text size" }, { "type": "range", "id": "title_size", "min": 16, "max": 40, "step": 2, "unit": "px", "label": "Tier title size", "default": 24 }, { "type": "range", "id": "points_size", "min": 12, "max": 30, "step": 1, "unit": "px", "label": "Points text size", "default": 18 }, { "type": "range", "id": "text_size", "min": 12, "max": 24, "step": 1, "unit": "px", "label": "Description text size", "default": 16 } ], "blocks": [ { "type": "tier", "name": "Tier", "settings": [ { "type": "image_picker", "id": "image", "label": "Image" }, { "type": "text", "id": "title", "label": "Title", "default": "Gold Tier" }, { "type": "text", "id": "points", "label": "Points text", "default": "1000+ points" }, { "type": "richtext", "id": "description", "label": "Description", "default": "

Exclusive access to new products, early bird discounts, and priority customer support.

" }, { "type": "header", "content": "Colours" }, { "type": "color", "id": "card_bg", "label": "Background colour", "default": "#ffffff" }, { "type": "range", "id": "card_opacity", "min": 0, "max": 100, "step": 5, "unit": "%", "label": "Background opacity", "default": 10 }, { "type": "color", "id": "text_color", "label": "Text colour", "default": "#ffffff" } ] } ], "presets": [ { "name": "VIP tiers", "blocks": [ { "type": "tier" }, { "type": "tier" }, { "type": "tier" } ] } ] } {% endschema %}

Step-by-Step: Adding the Custom VIP Tiers Section to Your Shopify Theme

Implementing this custom section is straightforward, even if you're new to theme code editing:

  1. Access Your Theme Code: From your Shopify admin, go to Online Store > Themes. Find the theme you want to edit (it's always a good idea to duplicate your theme first for a backup!), click the ... (Actions) button, and then select Edit code.
  2. Create a New Section File: In the left sidebar, locate the sections folder. Click Add a new section. Name the new file vip-tiers and click 'Done'.
  3. Paste the Code: Delete any pre-filled code in the new vip-tiers.liquid file. Then, copy the entire code block provided above (including the