Block 21 of 297
Comparison Table
Compare two to four plans or options feature by feature in a real table with a pinned first column.
- Puck key
- ComparisonTableBlock
- Export
- comparisonTableBlock
- React component
- <ComparisonTable />
- Path
- components/puck/comparison-table-block.tsx
- Dependencies
- None
- License
- MIT
About this block
When to use it, how to write for it, and what to change in the code.
What it's for
A true HTML table comparing two to four options, such as plans, memberships or rental spaces, row by row. Yes and no values turn into check and cross icons, other text shows as written, and rows can be grouped under header rows. On phones the table scrolls sideways while the feature column stays pinned.
- Comparing rental spaces, shelters or facilities
- Membership levels or sponsorship tiers
- Program options with different hours, ages or costs
Writing the content
- Type each row's Values in column order separated by |, like "yes | no | Up to 40". A missing value shows a dot read as "Not listed".
- Rows sharing the same Group sit together; a new header row starts only when the Group changes from the row above, so keep groups contiguous.
- Use Detail for the price or one-line summary under each option Name, and add Button text only where there's a real next step.
- Pick one Highlight column at most and give it a factual Highlight label, like "Most booked".
Accessibility
- Uses table, caption, column headers, row headers and colgroup header cells, so screen readers announce the option and feature for each cell (WCAG 1.3.1).
- Check and cross icons are aria-hidden and paired with hidden "Included" and "Not included" text, so meaning isn't carried by icon or color alone (WCAG 1.1.1, 1.4.1).
- The scroll container is a labeled, focusable region, so keyboard users can scroll it; each button adds the option name for screen readers.
Customizing the code
- The YES and NO regular expressions at the top decide which words become icons; add your own terms there.
- Highlight styling uses bg-indigo-50 and bg-indigo-600; the table's minimum width before scrolling is min-w-xl.
Editor fields
What content editors see in the P1 sidebar when they select this block.
- Headingtext
- Heading levelselect
- Introtextarea
- Options (columns)array
- Highlight columnselect
- Highlight labeltext
- Rowsarray
- Footnotetextarea