Back to Shopify Liquid
Tabs with images
Shopify Liquid

Tabs with images

A versatile product information tab system that supports rich media, including step-by-step image guides, two-column layouts, and standard text blocks. It features a responsive grid that toggles visibility via JavaScript and includes CSS transitions for smooth active state switching.

MediumProduct PageTabsCRODescriptionShipping
268 lines · 7.6 KB
Setup 15–25 minutes 5 min read 268 lines
Key features
  • Step-by-step visual guide layout
  • Responsive two-column grid support
  • Dynamic tab switching with active states
  • Mobile-optimized text & image stacking
  • CSS-based fade transitions
Best use cases
  • Displaying 'How to Use' instructions with icons
  • Organizing lengthy product specs and shipping policies
  • Creating a clean, decluttered product description area
  • Highlighting key ingredients or materials with imagery
Compatibility
  • Shopify Online Store 2.0
  • Most Shopify themes

The code

Shopify Liquid
1<!DOCTYPE html>
2<html lang="en">
3
4<head>
5 <meta charset="UTF-8" />
6 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7 <title>Product Info Tabs</title>
8 <style>
9 .tabs-container {
10 max-width: 1000px;
11 margin: 0 auto;
12 overflow: hidden;
13 }
14
15 .tabs-header {
16 display: flex;
17 max-width: 1200px;
18 justify-content: center;
19 center: ;
20 align-items: center;
21 margin: auto;
22 border-bottom: 1px solid #B3B3B3;
23 padding: 0px 70px;
24 }
25
26 @media screen and (max-width: 768px) {
27 .tabs-header {
28 display: flex;
29 max-width: 700px;
30 justify-content: center;
31 center: ;
32 align-items: center;
33 margin: auto;
34 border-bottom: 1px solid #B3B3B3;
35 padding: 0px 0px;
36 }
37 }
38
39 @media screen and (max-width: 768px) {
40 .tab {
41 font-size: 12px!IMPORTANT;
42 }
43 }
44
45 .tab {
46 flex: 1;
47 padding: 8px 8px;
48 text-align: center;
49 font-weight: bold;
50 cursor: pointer;
51 background: #fff;
52 color: #1a1817;
53 max-width: 100%;
54 box-sizing: border-box;
55 align-items: center;
56 display: flex;
57 justify-content: center;
58 font-size: 13px;
59 transition: background-color 0.8s ease;
60 }
61
62 .tab.active {
63 border-bottom: 4px solid #0C3D3D;
64 color: #1a1817;
65 }
66
67 .tab-content {
68 padding: 5px 0px;
69 display: none;
70 font-size: 13px;
71 transition: opacity 0.5s ease;
72 color: #1a1817;
73 }
74
75 .tab-content.active {
76 display: block;
77 background: #fff;
78 opacity: 1;
79 }
80 .flex-container {
81 display: flex;
82 flex-wrap: wrap;
83 justify-content: center;
84 }
85
86 .item-box {
87 margin: 0px 0px;
88 text-align: center;
89
90 }
91
92 .item-box img {
93 width: 33%;
94border-radius: 0px;
95 }
96
97 .item-title {
98 margin: 5px 0;
99font-weight: 600;
100 }
101
102 .item-description {
103 margin: 5px 0;
104 }
105
106
107 @media (min-width: 768px) {
108 .item-box {
109 flex: 0 0 30%;
110 display: flex;
111 flex-direction: column;
112 align-items: center;
113 }
114 .item-box img {
115 width: 30%;
116margin-bottom: 15px;
117min-width: 150px;
118 }
119 .flex-container{
120 display: flex;
121 flex-wrap: wrap;
122 max-width: 1200px;
123 align-content: center;
124 margin-top: 20px;
125 }
126}
127
128
129 @media (max-width: 767px) {
130 .flex-container {
131 flex-direction: column;
132 }
133 .item-box img {
134 width: 32%!important;
135 }
136
137 .item-box {
138 display: flex;
139 flex-direction: row;
140 align-items: center;
141 justify-content: center;
142 flex-wrap: wrap;
143 }
144
145 .item-box:nth-child(odd) {
146 flex-direction: row-reverse;
147 }
148
149 .item-box img, .item-box .text-content {
150 width: 60%;
151 }
152 }
153 .image1 {
154 flex: 1;
155 display: flex;
156 justify-content: center;
157 align-items: center;
158 }
159 .image1 img {
160 min-width: 100%;
161 height: auto;
162 border-radius: 5px;
163 }
164 .text1 {
165 flex: 1;
166 align-items: flex-start;
167 line-height: 24px;
168 margin-top: 0px;
169 text-align:center;
170 }
171 .text1 p {
172 font-size: 16px!important;
173 color: #2e2f3c;
174 }
175.containerv9 {
176 display: grid;
177 grid-template-columns: 1fr 1fr;
178 align-items: center;
179 padding-top: 5px;
180 padding-bottom: 20px;
181 gap:20px;
182}
183@media (max-width: 768px) {
184 .containerv9 {
185 grid-template-columns: 1fr;
186 grid-template-rows: auto auto;
187 }
188}
189 </style>
190</head>
191
192<body>
193 <div class=" page-width">
194 <div class="tabs-container">
195 <div class="tabs-header">
196 <div class="tab active" onclick="showTabContent('material')">
197 3 STEPS
198 </div>
199 <div class="tab" onclick="showTabContent('description')">DESCRIPTION</div>
200 <div class="tab" onclick="showTabContent('shipping')">SHIPPING</div>
201 <div class="tab" onclick="showTabContent('returns')">RETURNS</div>
202 </div>
203
204
205 <div id="material" class="tab-content active">
206 <div class="flex-container">
207 <div class="item-box">
208 <img src="https://cdn.shopify.com/s/files/1/0914/3228/8605/files/34.png?v=1737759137" alt="Image 1">
209 <div class="text-content">
210 <h4 class="item-title">Scoop</h4>
211 <p class="item-description">Description 1 goes here</p>
212 </div>
213 </div>
214 <div class="item-box">
215 <img src="https://cdn.shopify.com/s/files/1/0914/3228/8605/files/35.png?v=1737759137" alt="Image 2">
216 <div class="text-content">
217 <h4 class="item-title">Shake!</h4>
218 <p class="item-description">Description 2 goes here</p>
219 </div> </div>
220 <div class="item-box">
221 <img src="https://cdn.shopify.com/s/files/1/0914/3228/8605/files/36.png?v=1737759138" alt="Image 3">
222 <div class="text-content">
223 <h4 class="item-title">Enjoy</h4>
224 <p class="item-description">Description 3 goes here</p>
225 </div>
226 </div>
227 </div>
228 </div>
229
230
231 <div id="description" class="tab-content">
232<div class = "containerv9"
233 <div class="image1">
234 <img src="https://cdn.shopify.com/s/files/1/0914/3228/8605/files/51b0c232-93f7-4be9-9597-4233496b9b41.__CR0_0_2196_900_PT0_SX1464_V1.jpg?v=1737759255" width = "100%">
235
236 <p class="text1">A science-driven supplement supporting physical health and mental performance.
237Since 2010, AG1 combines the power of multiple supplements like vitamins, antioxidants and gut-friendly bacteria into just one scoop, making it your simplest daily health habit!</p>
238
239 </div>
240
241 </div>
242 <div id="shipping" class="tab-content">
243 <p>
244 shipping details and link goes here
245 </p>
246 </div>
247 <div id="returns" class="tab-content">
248 <p>
249 If you’re not 100% satisfied, contact us within 30 days of your first order to initiate the process of receiving a refund on your original order.
250 </p><br>
251<strong>Email |</strong> support.uk@drinkag1.com
252 </div>
253 </div>
254 </div>
255
256 <script>
257 function showTabContent(tabId) {
258 const tabs = document.querySelectorAll('.tab');
259 const tabContents = document.querySelectorAll('.tab-content');
260 tabs.forEach(tab => tab.classList.remove('active'));
261 tabContents.forEach(content => content.classList.remove('active'));
262 document.querySelector(`[onclick="showTabContent('${tabId}')"]`).classList.add('active');
263 document.getElementById(tabId).classList.add('active');
264 }
265 </script>
266</body>
267
268</html>

How to install Tabs with images on your Shopify theme

This snippet belongs in sections/main-product.liquid, below the product description, where shoppers look for answers. Expect the whole job to take about 15–25 minutes.

  1. 1From your Shopify admin, open Online Store → Themes, click the button on your live theme and choose Duplicate. Always work on a copy so you can roll back instantly.
  2. 2On the duplicated theme, click … → Edit code to open the theme code editor.
  3. 3Open sections/main-product.liquid in the file tree. If your theme uses different file names, search for the template that renders the area where you want the block to show up.
  4. 4Click Copy code on this page, then paste the snippet below the product description, where shoppers look for answers.
  5. 5The snippet ships with its own scoped <style> block, so you do not need to touch base.css or theme.css. If you prefer to keep CSS centralised, move the contents of the style tag into your theme stylesheet and delete the inline block.
  6. 6Keep the <script> tag at the end of the snippet. It only runs once the surrounding markup exists in the DOM, so moving it higher up the file can break the behaviour.
  7. 7Click Save, then hit Preview and check the block on desktop, tablet and mobile widths.
  8. 8When you are happy with the result, publish the duplicated theme from Online Store → Themes → Actions → Publish.

How to customise it

Every value below lives inside the snippet, so you can adapt Tabs with images to your brand without touching the rest of the theme.

  • Colours — the snippet uses #B3B3B3, #fff, #1a1817, #0C3D3D. Replace those values inside the style block with your brand palette, keeping at least a 4.5:1 contrast ratio between text and background so the block stays accessible.
  • Sizing — adjust the font-size values (12px!IMPORTANT, 13px, 16px!important) and the padding so the block carries the same visual weight as the elements around it.
  • Cornersborder-radius: 0px controls the roundness. Set it to 0 for a sharper editorial look, or increase it for a softer, app-like feel.
  • Images — replace the placeholder image URLs with your own assets. Upload them under Content → Files in Shopify admin and use the generated CDN URL, or reference a theme asset with {{ 'my-image.png' | asset_url }}.
  • Copy — rewrite the hard-coded text (for example “Product Info Tabs”) in your own brand voice, and translate it if you sell in more than one language.
  • Responsive behaviour — the @media query defines the mobile breakpoint. Adjust the pixel value if your theme uses a different breakpoint scale.

Common mistakes to avoid

These are the issues merchants run into most often when installing a snippet like this one.

  • Editing the live theme directly. Duplicate it first — a single unbalanced Liquid tag can take a storefront down mid-campaign.
  • Pasting the code into the wrong file. Dropped into layout/theme.liquid instead of sections/main-product.liquid, this block will render on every page of the store, including ones where it makes no sense.
  • Renaming the CSS classes in the markup but not in the style block, or vice versa. The class names have to match exactly or the styling silently disappears.
  • Adding the snippet twice on the same page. The script targets its selector, so two copies can conflict or double-fire.
  • Publishing without testing on a real phone. Most Shopify traffic is mobile, and layout problems almost always surface there first.

Performance notes

What this block costs you in load time, and how to keep that cost at zero.

  • The CSS is inline and scoped to this block, so it adds no extra network request. At a few kilobytes it has no measurable effect on your Lighthouse score.
  • The JavaScript is vanilla — no jQuery, no external library, no additional request. Keep it after the markup so it never blocks rendering.
  • Add loading="lazy" plus explicit width and height attributes to every image in the snippet. That prevents Cumulative Layout Shift, which is a Core Web Vitals ranking factor.
  • Run PageSpeed Insights before and after you add the block so you have a concrete number rather than a guess.

SEO & accessibility

How to add this block without damaging your on-page structure or your rich results.

  • Nothing in this snippet should replace your page <h1>. Keep product and page headings intact and use <h2> or <h3> for the block's own heading so the document outline stays clean.
  • Write a descriptive alt attribute for every image. Empty or generic alt text is one of the most common accessibility and SEO issues on Shopify stores.
  • If the block shows review or rating content, keep it consistent with the structured data your review app already outputs. Duplicating or contradicting rating markup can cost you the rich result entirely.
  • The block does not create a new URL, so there is no canonical or indexing change to make. It improves on-page engagement signals rather than crawlability.
Frequently asked questions

Tabs with images — questions merchants ask

Will this snippet work with my theme?

It is built with standard Liquid, HTML and CSS, so it works with Dawn and virtually every Online Store 2.0 theme, as well as most vintage themes. The only thing that changes between themes is the file you paste it into — if yours has no sections/main-product.liquid, look for the equivalent template that renders the same area.

Do I need an app to use it?

No. This is theme code you own outright: no monthly fee, no third-party script tag, and no app that can break your storefront the next time it updates.

How long does it take to add “Tabs with images” to a store?

Most merchants have it live in under fifteen minutes — duplicate the theme, paste the code, adjust the colours and copy, preview on mobile, publish.

The block appears but nothing happens. What is wrong?

That is almost always a script-order problem. Check that the script tag is still at the bottom of the snippet and that the markup was not pasted inside another script or a Liquid comment block. Open your browser console and look for an error naming the snippet's selector.

The styling looks broken after pasting. How do I fix it?

Confirm you copied the whole snippet including the closing style tag, then check whether one of your theme's own CSS rules is overriding it. If a theme rule wins, increase the specificity of the snippet's selector rather than scattering !important through the file.

Will it slow my store down?

Not meaningfully. It is inline markup with scoped CSS and at most a few lines of vanilla JavaScript — no external libraries, no extra HTTP request. Optimising your product images will always have a far bigger impact on load time.

Can I use it on a client store or a commercial project?

Yes. Every snippet in the MCO Hub library is free to copy, modify and ship on any store, including client work. Attribution is appreciated but not required.

Related snippets

Keep exploring