Comparator Stack
A stacked plan-card comparison — one card per plan with its own price, CTA, and per-plan feature checklist.
import type { Block } from 'payload'import { comparatorFields } from '@/blocks/shared/comparatorFields'import { linkGroup } from '@/fields/linkGroup'export const ComparatorStack: Block = { slug: 'comparatorStack', interfaceName: 'ComparatorStackBlock', fields: [ // Shared comparator header (title, description). Variant-specific fields // follow; edit the shared shape in @/blocks/shared/comparatorFields. ...comparatorFields, { name: 'plans', type: 'array', required: true, minRows: 2, maxRows: 4, admin: { initCollapsed: true, }, fields: [ { name: 'name', type: 'text', required: true, }, { name: 'description', type: 'text', }, { name: 'price', type: 'text', }, { name: 'period', type: 'text', admin: { description: 'Shown next to the price, e.g. "/month".', }, }, { name: 'badge', type: 'text', admin: { description: 'Optional pill beside the plan name, e.g. "Most popular".', }, }, { name: 'highlighted', type: 'checkbox', admin: { description: 'Adds an accent ring to draw the eye to the recommended plan.', }, }, linkGroup({ overrides: { maxRows: 1, }, }), { name: 'features', type: 'array', admin: { initCollapsed: true, }, fields: [ { name: 'label', type: 'text', required: true, }, { name: 'included', type: 'checkbox', }, { name: 'value', type: 'text', admin: { description: 'Text value for this feature. Leave "included" unticked and this empty for an excluded feature.', }, }, ], }, ], }, ], labels: { plural: 'Comparator Stack Blocks', singular: 'Comparator Stack', },}import React from 'react'import { Check, Minus } from 'lucide-react'import type { ComparatorStackBlock as ComparatorStackBlockData } from '@/payload-types'import { CMSLink } from '@/components/Link'import { Badge } from '@/components/ui/badge'import { Card } from '@/components/ui/card'import { cn } from '@/utilities/ui'type Props = ComparatorStackBlockData & { id?: string className?: string disableInnerContainer?: boolean}export const ComparatorStackBlock: React.FC<Props> = ({ className, description, disableInnerContainer, id, plans, title,}) => { return ( <section className={cn('container', className)} id={id ? `block-${id}` : undefined}> <div className="overflow-hidden rounded-frame border border-border/70 bg-card/35 px-6 py-10 sm:px-8 lg:px-12 lg:py-14"> <div className={cn('flex flex-col gap-10', { 'mx-auto max-w-3xl': !disableInnerContainer, })} > {title || description ? ( <div className="flex flex-col items-center gap-4 text-center"> {title ? ( <h2 className="text-4xl font-medium tracking-display text-balance sm:text-5xl">{title}</h2> ) : null} {description ? ( <p className="max-w-xl text-base leading-7 text-muted-foreground sm:text-lg">{description}</p> ) : null} </div> ) : null} {plans && plans.length > 0 ? ( <div className="flex flex-col gap-4"> {plans.map((plan, planIndex) => ( <Card key={plan.id ?? planIndex} className={cn('border-border/70 bg-background/60 p-6 shadow-none', { 'ring-1 ring-primary': plan.highlighted, })} > <div className="flex flex-col gap-6 lg:flex-row lg:items-start lg:justify-between"> <div className="lg:max-w-xs"> <div className="flex flex-wrap items-center gap-2"> <h3 className="text-lg font-medium text-foreground">{plan.name}</h3> {plan.badge ? ( <Badge variant="outline" className="rounded-full px-2 py-0.5 text-xs uppercase tracking-eyebrow" > {plan.badge} </Badge> ) : null} </div> {plan.description ? ( <p className="mt-1 text-sm text-muted-foreground">{plan.description}</p> ) : null} <div className="mt-4 flex items-baseline gap-1"> <span className="text-3xl font-medium tracking-title text-foreground">{plan.price}</span> {plan.period ? <span className="text-sm text-muted-foreground">{plan.period}</span> : null} </div> {plan.links && plan.links.length > 0 ? ( <div className="mt-4 flex flex-col gap-2"> {plan.links.map(({ link }, linkIndex) => ( <CMSLink key={linkIndex} appearance={link.appearance === 'outline' ? 'outline' : 'default'} {...link} /> ))} </div> ) : null} </div> {plan.features && plan.features.length > 0 ? ( <div className="w-full lg:w-72 lg:shrink-0"> {plan.features.map((feature, featureIndex) => ( <div key={feature.id ?? featureIndex} className="flex items-center justify-between border-b border-border/70 py-3 text-sm last:border-b-0" > <span className="text-muted-foreground">{feature.label}</span> {feature.included ? ( <Check aria-label="Included" className="size-4 text-primary" role="img" /> ) : feature.value ? ( <span className="font-medium text-foreground">{feature.value}</span> ) : ( <Minus aria-label="Not included" className="size-4 text-muted-foreground" role="img" /> )} </div> ))} </div> ) : null} </div> </Card> ))} </div> ) : null} </div> </div> </section> )}import type { Field } from 'payload'/** * Shared field core for the Comparator component family. * * Every comparator variant (comparator-table, comparator-grid, comparator-stack) * spreads this optional section header first and then appends its own plan/feature * shape — the feature matrix for the table and grid layouts, or the per-plan * checklists for the stacked layout. Editing the shared title/description here * updates every installed comparator block at once, so the family never drifts * field-by-field across a repo. * * Installed once per repo at `src/blocks/shared/comparatorFields.ts`; re-running * `payload-components add comparator-*` never overwrites a copy you have already edited. */export const comparatorFields: Field[] = [ { name: 'title', type: 'text', }, { name: 'description', type: 'textarea', },]Installation
npx payload-components add comparator-stackCopy the files straight from the registry, then wire the Payload fragments by hand:
pnpm dlx shadcn@latest add https://www.payload-components.xyz/r/comparator-stack.jsonWhat it installs
Copies 3 source files into your project:
src/blocks/shared/comparatorFields.tssharedsrc/blocks/ComparatorStack/config.tssrc/blocks/ComparatorStack/Component.tsx
…and makes 4 edits to wire the block into your project:
| Registers the block | src/collections/Pages/index.ts |
| Maps the renderer | src/blocks/RenderBlocks.tsx |
| Regenerates types | src/payload-types.ts |
| Regenerates the admin import map | src/app/(payload)/admin/importMap.js |
comparatorFields.ts is the shared field core for this family — every variant composes it. Editing it updates each installed block at once, and re-running an install never overwrites a copy you have changed.Re-running the install converges: it detects existing wiring, skips it, and records install state in .payload-components/state.json.
Content model
title and description come from the shared Comparator family base
(src/blocks/shared/comparatorFields.ts); the plans stack is specific to this variant. Unlike the
table and grid variants, each plan carries its own features checklist rather than sharing one
matrix — good for mobile-first, plan-centric pages.
Prop
Type
Each item in plans carries:
Prop
Type
Each item in a plan's features carries:
Prop
Type
Usage
ComparatorStack block to its layout.RenderBlocks on the frontend, fully typed — no extra wiring.Requirements
- Target
- payload-website-starter
- Payload
- v3
- Next.js
- 15 / 16
- shadcn UI
- badge, card
Your project must already expose components.json, src/payload.config.ts, src/blocks/RenderBlocks.tsx, src/collections/Pages/index.ts — the surfaces payload-components add patches. The CLI verifies this against the support matrix before touching anything.
In this family
comparator-tablecomparator-gridcomparator-stackcurrent