Menu
All plugins

Comparison Table for Bricks

A nestable Bricks element for comparing plans, products or options side by side. Wide spaces get a table with a label column. Narrow spaces get one card per plan. The plans can be typed in or pulled from a query loop.

Version: 0.1.1 · Requires: WordPress 6.0+, PHP 8.1+, Bricks · See the live demo

What it does

  • One column per plan, with a shared label column down the left and aligned rows across the table.
  • Highlights one plan, by position or with a class.
  • Scrolls sideways, with the label column staying in place, if there are too many plans for the space.
  • Becomes a card for each plan below a width you choose, with each value labelled. It follows the space the table sits in, so it also works in a sidebar.
  • Works with a query loop, and counts the plans and rows by itself.

Installation

  1. Upload and activate the plugin. Bricks must be active.
  2. In the Bricks editor search for Comparison Table (Layout group). It arrives with a label column and three sample plans.

Quick start

  1. Edit the labels in the label column. Each label is one row.
  2. Edit the values in each plan, in the same order as the labels.
  3. Add a plan with the plus button on the element in the structure panel, or by duplicating a plan.
  4. To add a row, duplicate a cell in the label column and in every plan.

How it is built

  • The element holds a label block (class ct-labels) and a plan block for each plan (class ct-plan). Every cell has the class ct-cell.
  • The first cell of every block is the header (class ct-head) and the last can be the action (class ct-action). Neither shows a label on the cards.
  • On cards, every other value takes its label from the label cell in the same position. To override one, add a data-label attribute.

Using it in a loop, including an ACF repeater

The loop can be a post, term or user query, or a repeater such as an ACF repeater or a Meta Box group. For a repeater, choose it as the loop type on the item block, then use its sub-fields in the dynamic data. The demo includes an example built from an ACF repeater.

Keep the label block, then put the query loop on a single plan block. There is a column for each result.

  1. Delete all but one plan.
  2. On the plan block, switch on Query loop and choose what to list.
  3. Fill the header with Comparison Table for Bricks and the other cells with dynamic data, such as custom fields. Link the action button to https://bricks-playground.co.uk/docs/comparison-table/.
  4. Keep the same number of cells as the label block has.

The number of columns and rows is worked out from the result, so nothing else needs setting.

Settings

Layout

  • Switch to cards at (px) — in a space this wide or narrower each plan becomes a card (default: 640; 0 keeps the table at every width)
  • Highlight plan number — counts from 1. With a query loop, add the class ct-hot to the plan block instead
  • Label column width and Minimum plan width

Table

  • Cell padding, Corner radius, Background, Row divider colour, Header cell background, Highlighted plan background, Label text colour

Cards

  • Gap between cards, Card padding, Corner radius, Background, Shadow, Highlighted card outline

Tips

  • Keep label text short. It repeats on every card.
  • Use the header cell for a name and a price.
  • A plan can hold any Bricks element in its cells, such as ticks, icons, badges or buttons.

Known limits

  • Every plan needs the same number of cells as the label block, in the same order.
  • The card labels are filled in by a small script after the page loads. Without JavaScript the cards still show, without labels.