Back to Shopify Liquid
Shopify Reviews
Shopify Liquid

Shopify Reviews

A dynamic customer testimonial carousel utilizing Swiper.js. It features a unique CSS-driven floating animation for review cards, star ratings (including partial stars), and verified buyer badges.

MediumReviewsTrustCROProduct PageTestimonials
272 lines · 10.0 KB
Setup 15–25 minutes 6 min read 272 lines
Key features
  • Animated floating CSS effects (up/down) for cards
  • Swiper.js powered touch-friendly slider controls
  • Verified buyer badge integration with external assets
  • Responsive layout with mobile-hidden navigation arrows
  • Custom star rating rendering including half-star gradients
Best use cases
  • Displaying social proof on the home or product page
  • Creating an engaging, animated customer feedback section
Compatibility
  • Most Shopify themes

The code

Shopify Liquid
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="UTF-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1.0">
6 <title>Card Slider with Swiper</title>
7 <!-- Swiper CSS -->
8 <link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.min.css">
9 <style>
10
11 #card-container {
12 width: 100%;
13 margin: 0 auto;
14 overflow: hidden;
15 position: relative;
16
17 }
18 .swiper-wrapper {
19 min-width: 100%; /* Set a minimum width to prevent excessive compression */
20 box-sizing: content-box; /* Ensure the width includes padding and border, but not margin */
21}
22
23 .swiper-container {
24 width: calc(100% - 20px);
25 position: relative;
26 margin: 0 auto;
27padding: 10px 0px;
28 }
29
30@keyframes upAndDown {
31 0%, 100% {
32 transform: translateY(0); /* Original position */
33 }
34 25% {
35 transform: translateY(-4px);
36 }
37 50% {
38 transform: translateY(0px);
39 }
40 75% {
41 transform: translateY(4px);
42 }
43}
44
45@keyframes downAndUp {
46 0%, 100% {
47 transform: translateY(0); /* Original position */
48 }
49 25% {
50 transform: translateY(4px);
51 }
52 50% {
53 transform: translateY(0px);
54 }
55 75% {
56 transform: translateY(-4px);
57 }
58}
59
60.swiper-slide:nth-child(odd) {
61 animation: upAndDown 4s infinite linear;
62}
63
64.swiper-slide:nth-child(even) {
65 animation: downAndUp 4s infinite linear;
66}
67
68
69.swiper-slide {
70 max-width: 280px;
71 height: 230px;
72 box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
73 display: flex;
74 flex-direction: column;
75 align-items: center;
76 background-color: #fff;
77 border: 2px solid rgb(239, 239, 243);
78 border-radius: 5px;
79 padding: 11px;
80 box-sizing: border-box;
81 justify-content: space-between;
82 gap: 15px;
83}
84
85
86
87 .rating {
88 font-size: 32px;
89 color: #f7d131;
90 margin-top: 10px;
91line-height: 20px;
92 }
93
94 .description {
95 font-size: 14px;
96 color: #333;
97 text-align: center;
98 justify-content: space-between;
99 line-height: 22px;
100 }
101.name{
102 display: flex;
103 align-items: center;
104 gap: 5px;
105}
106
107
108
109 .swiper-button-prev, .swiper-button-next {
110 color: white;
111 font-size: 15px!important;
112 background-color: #333;
113 width: 30px;
114 height: 30px;
115 border-radius: 50%;
116 margin: 0 10px;
117 top: 42%!important;
118 }
119
120 @media (max-width: 767px) {
121 .swiper-button-prev, .swiper-button-next {
122 display: none;
123 }
124 }
125
126 .swiper-pagination {
127 position: relative;
128 top: auto;
129 left: auto;
130 right: auto;
131 margin-top: 30px;
132 display: flex;
133 justify-content: center;
134 align-items: center;
135 }
136
137 .swiper-pagination-bullet {
138 width: 0.5rem;
139 height: 0.5rem;
140 background-color: #0d437d;
141 margin: 0 5px;
142 border-radius: 2px;
143 cursor: pointer;
144 }
145
146 .swiper-pagination-bullet-active {
147 width: 1.5rem;
148 background-color: #0d437d;
149 border-radius: 4px;
150 }
151 .swiper-button-next:after,.swiper-button-prev:after {
152 font-family: swiper-icons;
153 font-size: 15px;
154 text-transform: none!important;
155 letter-spacing: 0;
156 font-variant: initial;
157 line-height: 1
158}
159
160 </style>
161
162
163
164
165
166
167<div class="container">
168 <div id="card-container">
169 <div class="swiper-container">
170 <div class="swiper-wrapper">
171 <div class="swiper-slide">
172 <div class="rating">★★★★★</div>
173 <div class="description">"I much prefer them over liquid detergent because they are easy to store, clean to use and I love that you can rip the sheets if you want to change the amount you are using."</div>
174 <div class = "name"> <font style = "color: #13152f!important; font-weight: bold;">Davina K</font> <img src="https://cdn3.emoji.gg/emojis/9796-verified.png" width="20px" height="20px" alt="Verified"> <font style = "font-size: 12px; color: #13152f;" >Verified</font></div>
175 </div>
176 <div class="swiper-slide">
177 <div class="rating">★★★★★</div>
178 <div class="description">"I'm impressed so far with the cleaning power, as well as the convenience. Of course limited packaging waste is a big win, too!"</div>
179 <div class = "name"> <font style = "color: #13152f!important; font-weight: bold;">Aliza</font> <img src="https://cdn3.emoji.gg/emojis/9796-verified.png" width="20px" height="20px" alt="Verified"> <font style = "font-size: 13px; color: #13152f;" >Verified</font></div>
180 </div>
181 <div class="swiper-slide">
182 <div class="rating">★★★★★</div>
183 <div class="description">Very simple detergent, does the job just as good, small pacakging, great product"</div>
184 <div class = "name""> <font style = "color: #13152f!important; font-weight: bold;">Jayna H</font> <img src="https://cdn3.emoji.gg/emojis/9796-verified.png" width="20px" height="20px" alt="Verified"> <font style = "font-size: 13px; color: #13152f;" >Verified</font></div>
185 </div>
186<div class="swiper-slide">
187 <div class="rating">
188 <span style="color: #f7d131;"></span><span style="color: #f7d131;"></span><span style="color: #f7d131;"></span><span style="color: #f7d131;"></span><span style="color: #DDDDDD;"></span>
189 </div>
190 <div class="description" style = "margin-top:10px">
191 "Yes very happy with the product. I bought it to use when travelling in our caravan. Light and convenient. Tested it on clothes at home and seems to work very well."
192 </div>
193 <div class = "name"> <font style = "color: #13152f!important; font-weight: bold;">Ally</font> <img src="https://cdn3.emoji.gg/emojis/9796-verified.png" width="20px" height="20px" alt="Verified"> <font style = "font-size: 13px; color: #13152f;" >Verified</font></div>
194</div>
195
196 <div class="swiper-slide">
197 <div class="rating">★★★★★</div>
198 <div class="description">"
199 i used to get rashes before using these sheets, well not anymore, thank you so much!
200 "</div>
201 <div class = "name" > <font style = "color: #13152f!important; font-weight: bold;">Mehul G</font> <img src="https://cdn3.emoji.gg/emojis/9796-verified.png" width="20px" height="20px" alt="Verified"> <font style = "font-size: 13px; color: #13152f;" >Verified</font></div>
202 </div>
203 <div class="swiper-slide">
204 <div class="rating">★★★★★</div>
205 <div class="description">"
206 Easy to order, easy to use and great washing results !
207 "</div>
208 <div class = "name"> <font style = "color: #13152f!important; font-weight: bold;">Noah D</font> <img src="https://cdn3.emoji.gg/emojis/9796-verified.png" width="20px" height="20px" alt="Verified"> <font style = "font-size: 13px; color: #13152f;" >Verified</font></div>
209 </div>
210<div class="swiper-slide">
211 <div class="rating">
212 <span style="color: #f7d131;"></span><span style="color: #f7d131;"></span><span style="color: #f7d131;"></span><span style="color: #f7d131;"></span><span style="background-image: linear-gradient(to right, #f7d131 50%, #dddddd 50%);
213 -webkit-background-clip: text !important;
214 -moz-background-clip: text !important;
215 -webkit-text-fill-color: transparent !important;"></span>
216 </div>
217 <div class="description">It has completely stopped my skin irritation, i never knew how harmful my liquid detergent was</div>
218 <div class = "name"> <font style = "color: #13152f!important; font-weight: bold;">Ada T</font> <img src="https://cdn3.emoji.gg/emojis/9796-verified.png" width="20px" height="20px" alt="Verified"> <font style = "font-size: 13px; color: #13152f;" >Verified</font></div>
219</div>
220
221<div class="swiper-slide">
222 <div class="rating">
223 <span style="color: #f7d131;"></span><span style="color: #f7d131;"></span><span style="color: #f7d131;"></span><span style="color: #f7d131;"></span><span style="color: #DDDDDD;"></span>
224 </div>
225 <div class="description">My shelves are now free for my other cleaning supplies, one neat tidy cupboard for all my supplies thanks to your compact detergent</div>
226 <div class = "name"> <font style = "color: #13152f!important; font-weight: bold;">Martha</font> <img src="https://cdn3.emoji.gg/emojis/9796-verified.png" width="20px" height="20px" alt="Verified"> <font style = "font-size: 13px; color: #13152f;" >Verified</font></div>
227</div>
228 </div>
229 <!-- Add Navigation Arrows -->
230 <div class="swiper-button-prev"></div>
231 <div class="swiper-button-next"></div>
232 <!-- Add Pagination -->
233 <div class="swiper-pagination"></div>
234 </div>
235 </div>
236</div>
237
238
239 <!-- Swiper JS -->
240 <script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>
241 <script>
242 document.addEventListener("DOMContentLoaded", function () {
243 var swiper = new Swiper('.swiper-container', {
244 slidesPerView: 'auto',
245 spaceBetween: 10,
246 navigation: {
247 nextEl: '.swiper-button-next',
248 prevEl: '.swiper-button-prev',
249 },
250 pagination: {
251 el: '.swiper-pagination',
252 clickable: true,
253 },
254 autoplay: {
255 delay: 10000, // Autoplay every 10 seconds
256 disableOnInteraction: false, // Allow manual navigation without stopping autoplay
257 },
258 breakpoints: {
259 1024: {
260 slidesPerView: 3,
261 },
262 1300: {
263 slidesPerView: 4,
264 },
265 },
266 });
267 });
268 </script>
269
270
271</body>
272</html>

How to install Shopify Reviews on your Shopify theme

This snippet belongs in sections/main-product.liquid, directly under the Add to cart button, where it reinforces the purchase decision. 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 directly under the Add to cart button, where it reinforces the purchase decision.
  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 Shopify Reviews to your brand without touching the rest of the theme.

  • Colours — the snippet uses #fff, #f7d131, #333, #0d437d. 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.
  • Gradient — swap the linear-gradient(...) declaration for a flat background colour if you want a more minimal, theme-native look.
  • Typography — the block declares font-family: swiper-icons. Delete that line to inherit your theme font instead, which usually looks better integrated.
  • Sizing — adjust the font-size values (32px, 14px, 15px!important) and the padding so the block carries the same visual weight as the elements around it.
  • Cornersborder-radius: 5px 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 “Card Slider with Swiper”) 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.
  • Leaving the demo images in place. They are hosted on third-party domains, can disappear at any time and slow the page down. Re-upload them to Shopify Files before going live.
  • 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.
  • The animation runs on CSS keyframes. Animate only transform and opacity where you can — animating width, height or top forces a layout recalculation on every frame.
  • Third-party image URLs bypass the Shopify CDN and add extra DNS lookups. Self-hosting those assets usually saves 100–300ms on first paint.
  • 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

Shopify Reviews — 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 “Shopify Reviews” 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