Skip to content

Product Comparison Table Section for Shopify

Shopify section with a real comparison table for 2 to 4 products: live prices, yes/no icons, row values set in the theme editor, and a sticky first column when it scrolls on phones.

Also known as: product comparison table, compare products table, side by side product comparison, product comparison chart

Preview with sample data

Open in new tab

Liquid code

A product comparison table for Shopify: a Liquid section that puts 2 to 4 products side by side, with live images, prices and availability, plus feature rows you write yourself in the theme editor. No app is needed.

How it works

The section outputs a real HTML table. Each column header holds a product's image and linked title, and the first row always shows its price. Sale prices appear with the compare-at price struck through, products with variable prices start with "From", and sold-out products get a small label. All of that comes from the products themselves.

The other rows are blocks. You add a Row block, give it a label and enter one value per product. Typing yes or no shows a check or cross icon, any other text is shown as written, and an empty value shows a dash. Below the rows, each column ends in a button linking to the product page.

On narrow screens the table keeps its column widths and scrolls sideways inside .wds-pc__scroll, so the page itself never overflows. The first column stays pinned with position: sticky and gains a soft shadow while scrolled, and the scroll hint appears only when the table really does not fit.

Customization

In the theme editor, the section is called WDS Product comparison:

  • Products: choose 2 to 4. Each row's values follow this order.
  • Row blocks: Label and Product 1 value to Product 4 value.
  • Heading, Subheading: the text above the table.
  • First column heading, Price row, Button, Price prefix for variable prices, Sold out, Scroll hint: visible labels.
  • Table description, Yes, No and the other labels under Screen reader labels.
  • Background, Text, Accent: colors. With a light accent, the button text and sale price switch to a darker color automatically.
  • Side padding, Top padding, Bottom padding: spacing.

Use cases

  • Online stores with similar products: compare two to four items side by side with live images and prices
  • Stores with sales: show sale prices with the compare-at price struck through and sold-out labels
  • Spec-heavy catalogs: write feature rows in the theme editor, using yes or no to show check icons
  • Mobile shoppers: keep the first column sticky while the table scrolls on small phones

Accessibility

It uses scope on row and column headers and a hidden caption. The scroll area is a focusable, labelled region, so keyboard users can scroll it with the arrow keys. Icons are hidden from screen readers and replaced by the text labels above, and each button's name includes its product. Focus outlines are visible, and motion is removed for prefers-reduced-motion.

Usage notes

It requires an Online Store 2.0 theme. Row values are typed by hand: they are not read from metafields or product data, so you must keep them accurate and update them when a product changes. If you reorder the products, the values do not move with them.

With products selected and no rows, the live store shows just prices and buttons. Sample rows appear only when no products are selected or in the theme editor.

The preview uses sample products and feature values for an invented store, and its links show a demo message instead of opening a page. Photos in the preview are from Unsplash; section.liquid contains none and uses your product images.

Product Comparison Table Section for Shopify at a glance

Framework
Shopify
Code
Liquid
JavaScript
Not needed
Dependencies
fonts.googleapis.com
Layout
Responsive, works on mobile
Category
Tables
License
Free for personal and commercial use

Questions about this section

Can I use the Product Comparison Table Section for Shopify code for free?

Yes. You can copy or download the Liquid code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my Shopify store?

Create a new section named shopify-product-comparison in your theme code editor, paste the Liquid code and save. Then add the section to a page in the theme editor. It works with Online Store 2.0 themes.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

How to install

  1. In your Shopify admin, go to Online Store > Themes, open the theme's menu and choose Edit code.
  2. Under Sections, add a new section named shopify-product-comparison, replace its contents with the Liquid code above and save.
  3. Open the theme editor, choose Add section and add it to the page.

Requires an Online Store 2.0 theme. Try it on a copy of your theme first. WebDevSnippets is not affiliated with or endorsed by Shopify.

Product Comparison Table Section for Shopify – Shopify tables component screenshot
Product Comparison Table Section for Shopify · Shopify Tables

More Tables

Table with Search Filter – Bootstrap 5 tables preview

Table with Search Filter

Bootstrap 5 team directory table with live search, status filter, highlighted matches, result counter and empty state.

Sortable Data Table – Tailwind CSS tables preview

Sortable Data Table

Tailwind CSS data table with clickable column headers that sort text, dates and numbers, with aria-sort, arrow indicators and a responsive scroll wrapper.

Table with Sticky Header – Pure CSS tables preview

Table with Sticky Header

Dark striped data table in pure CSS with a sticky header row and sticky first column inside a scrollable, keyboard-focusable container.

Responsive Table with Actions – Bootstrap 5 tables preview

Responsive Table with Actions

Responsive Bootstrap 5 invoice table with status badges, a status filter and row action dropdowns to mark as paid, remind or delete.