Comparison: two-plan matrix
A compact, responsive table comparing the features of two plans.
pnpm dlx shadcn@latest add @haze/comparison-plan-matrix---
import { cn } from "../../../lib/haze/utils";
interface Props {
id?: string;
eyebrow?: string;
title?: string;
description?: string;
headingLevel?: 1 | 2 | 3;
plans?: [string, string];
features?: { name: string; first: string; second: string }[];
class?: string;
}
const {
id = "comparison-plan-matrix",
eyebrow = "Compare plans",
title = "The details, side by side",
description = "Find the right starting point for your team. The values below are examples.",
headingLevel = 2,
plans = ["Starter", "Team"],
features = [
{ name: "Members", first: "Up to 3", second: "Unlimited" },
{ name: "Projects", first: "Up to 5", second: "Unlimited" },
{ name: "Activity history", first: "30 days", second: "1 year" },
{ name: "Guest access", first: "Not included", second: "Included" },
{ name: "Priority support", first: "Not included", second: "Included" },
],
class: className,
} = Astro.props;
const Heading = ({ 1: "h1", 2: "h2", 3: "h3" } as const)[headingLevel];
---
<section aria-labelledby={`${id}-title`} class={cn("bg-background px-6 py-20 sm:py-24", className)}>
<div class="mx-auto max-w-5xl">
<div class="max-w-2xl">
<p class="text-[0.6875rem]/4 font-medium tracking-wider text-muted-foreground uppercase">{eyebrow}</p>
<Heading id={`${id}-title`} class="mt-3 text-3xl/9 font-semibold tracking-tight text-balance text-foreground sm:text-4xl/11">{title}</Heading>
<p class="mt-4 text-base/7 text-pretty text-muted-foreground">{description}</p>
</div>
<div class="mt-10 overflow-hidden rounded-xl border border-border bg-card">
<table class="w-full table-fixed border-collapse text-left text-[0.8125rem]/5 sm:text-sm/6">
<caption class="sr-only">{title}</caption>
<thead>
<tr class="border-b border-border bg-foreground/5">
<th scope="col" class="w-2/5 px-3 py-4 font-medium text-muted-foreground sm:px-6">Feature</th>
{plans.map((plan) => <th scope="col" class="px-2 py-4 font-semibold text-foreground sm:px-6">{plan}</th>)}
</tr>
</thead>
<tbody class="divide-y divide-border">
{features.map((feature) => (
<tr>
<th scope="row" class="break-words px-3 py-4 font-medium text-foreground sm:px-6">{feature.name}</th>
<td class="break-words px-2 py-4 text-muted-foreground sm:px-6">{feature.first}</td>
<td class="break-words px-2 py-4 text-foreground sm:px-6">{feature.second}</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
</section>When to use
- A buyer needs to compare two plans feature by feature
- Plan values need clear text labels rather than icons alone
When not to use
- You need to present plan prices and calls to action; use pricing-three-tier
Installation
Add the Haze registry to components.json once, then install Comparison: two-plan matrix with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/comparison-plan-matrixnpx shadcn@latest add @haze/comparison-plan-matrixyarn dlx shadcn@latest add @haze/comparison-plan-matrixbunx --bun shadcn@latest add @haze/comparison-plan-matrixFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | "comparison-plan-matrix" | ID prefix for this labelled section. |
| eyebrow | string | "Compare plans" | Small label above the heading. |
| title | string | demo heading | Section heading and table caption. |
| description | string | demo copy | Introduction; replace the example-plan notice with your own copy. |
| headingLevel | 1 | 2 | 3 | 2 | Level of the section heading. |
| plans | [string, string] | ["Starter", "Team"] | Names for the first and second comparison columns. |
| features | { name: string; first: string; second: string }[] | 5 demo features | Feature names and their corresponding text values. |
| class | string | – | Additional classes on the section. |
Accessibility
- The native table identifies column and row headers and has a caption.
- Plan availability is written in text, so it is not conveyed by color or icons alone.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI block "Comparison: two-plan matrix" with `npx shadcn@latest add @haze/comparison-plan-matrix`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import ComparisonPlanMatrix from "@/components/haze/blocks/comparison-plan-matrix.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/blocks/comparison-plan-matrix.md
Customize with real content
Adapt the Haze comparison-plan-matrix block for our product. Replace the demo values of these props with our real content: id, eyebrow, title, description, headingLevel, plans, features, class. Keep the layout, the heading level rules and these accessibility details: The native table identifies column and row headers and has a caption. Plan availability is written in text, so it is not conveyed by color or icons alone. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using comparison-plan-matrix, check it fits: use it when a buyer needs to compare two plans feature by feature; plan values need clear text labels rather than icons alone. Avoid it when you need to present plan prices and calls to action; use pricing-three-tier. Alternatives: @haze/pricing-three-tier.
Dependencies
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.