Back to Shopify Liquid
Gradient Bar
Shopify Liquid

Gradient Bar

This snippet implements a slim, 5px high horizontal separator featuring a multi-stop linear gradient. It uses inline CSS to create a vibrant transition between green, violet, and yellow tones, acting as a decorative visual break between sections.

EasyDesign EnhancementSeparator LineGradient Bar decorationSection Divider
22 lines · 0.7 KB
Setup 5–10 minutes 3 min read 21 lines
Key features
  • Multi-stop CSS linear gradient
  • Zero-margin layout design
  • Full-width responsive container
  • Lightweight inline-styled element
Best use cases
  • Separating the header from the main navigation menu.
  • Adding a colorful visual accent above the footer.
  • Serving as a subtle divider between different homepage sections.
Compatibility
  • Most Shopify themes

The code

Shopify Liquid
1<!-- INICIO DE CODIGO - BARRA EN DEGRADE -->
2<div class="container-fluid color-line" style="
3margin: 0px 0px 0px; display: block!important;
4background: linear-gradient(to right,
5
6/* Inicio de cambiar color en degrade */
7rgba(0,178,108,1) 0%, rgba(4,180,154,1) 25%, rgba(128,255,15,1) 50%, rgba(192,109,255,1) 75%, rgba(255,229,20,1) 100%
8 /* Fin de cambiar color en degrade */
9
10 );
11height: 5px;
12width: 100%;
13background-image: linear-gradient(to right,
14
15/* Inicio de cambiar color en degrade */
16rgba(0,178,108,1) 0%, rgba(4,180,154,1) 25%, rgba(128,255,15,1) 50%, rgba(192,109,255,1) 75%, rgba(255,229,20,1) 100%
17 /* Fin de cambiar color en degrade */
18
19);
20"></div>
21<!-- FIN DE CODIGO - BARRA EN DEGRADE -->

How to install Gradient Bar on your Shopify theme

This snippet belongs in sections/main-product.liquid (or any section where you want it to appear), in the block of your template where it makes the most contextual sense. Expect the whole job to take about 5–10 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 (or any section where you want it to appear) 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 in the block of your template where it makes the most contextual sense.
  5. 5Click Save, then hit Preview and check the block on desktop, tablet and mobile widths.
  6. 6When 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 Gradient Bar to your brand without touching the rest of the theme.

  • Gradient — swap the linear-gradient(...) declaration for a flat background colour if you want a more minimal, theme-native look.

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.
  • 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.

  • This snippet is plain markup with no scripts and no external requests, so its performance cost is effectively zero.
  • 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.
  • 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

Gradient Bar — 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 “Gradient Bar” 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.

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