Xzero UI
Pro library

Comparison table

An us versus them table with a sticky header, a highlighted column, and a stacked phone view.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui/comparison-table
Live · keyboard ready

Use this on a pricing or alternatives page. Describe your columns and feature rows in comparison-table-data.ts, mark your product with highlight, and point the cta at signup; stickyTop offsets the header under a fixed site header.

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui/comparison-table

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { ComparisonTable } from "@/components/xzero/blocks/comparison-table/comparison-table";

export function Alternatives() {
  return (
    <ComparisonTable
      columns={[
        { id: "us", name: "Relay", caption: "$10 per seat", highlight: true },
        { id: "them", name: "Legacy suite", caption: "$24 per seat" },
      ]}
      sections={[{ id: "core", title: "Core", rows: [
        { id: "offline", feature: "Offline mode", values: { us: true, them: false } },
        { id: "sso", feature: "SSO", values: { us: true, them: { value: "partial", note: "Enterprise plan" } } },
      ] }]}
      cta={{ label: "Start free trial", href: "/signup" }}
      stickyTop={64}
    />
  );
}

API reference

ComparisonTable

An us versus them table with sections, check, partial and not included marks, a tinted band behind your column, a sticky frosted header, a differences only switch, and a stacked two column view on phones.

PropTypeDefaultDescription
columnsComparisonColumn[]–Products to compare. Mark yours with highlight: true.
sectionsComparisonSection[]–Grouped feature rows. Values: true, false, "partial", a string, or { value, note }.
titlestring"How Relay compares"Section heading.
descriptionstring–Line under the heading.
differencesOnlyboolean–Hide rows where all visible columns match (controlled).
defaultDifferencesOnlybooleanfalseInitial switch state when uncontrolled.
onDifferencesOnlyChange(value: boolean) => void–Called when the switch flips.
compareWithstring–Competitor shown beside yours in the stacked phone view (controlled).
onCompareWithChange(id: string) => void–Called when a competitor is picked on phones.
cta{ label: string; href?: string; onClick?: () => void; doneLabel?: string }–Button at the foot of your column. doneLabel morphs in after a click.
stickyTopnumber0Offset for the sticky header, such as a fixed site header height.
maxHeightnumber | string–Caps the table height and scrolls it inside the block with the header pinned.
stackBelownumber640Block width below which the phone view takes over.
classNamestring–Extra class on the section.

Keyboard interactions

KeysAction
TabMoves to the differences switch, the phone competitor picker, and the call to action.
SpaceFlips the differences switch.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Guidance for AI tools

Blocks are complete, self-contained screens with sample data. Replace the sample data and connect the callbacks described above. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components