Installation
npx shadcn@latest add @pixeldosa/feature-comparisonRequires `cn` at `@/lib/utils`. Feature values are rendered as provided; format labels and accessible descriptions for icon-only or abbreviated values in the consuming app.
Usage
<FeatureComparison
title="Choose the right way to work"
plans={[{ id: "starter", name: "Starter" }, { id: "team", name: "Team" }]}
features={[
{ id: "projects", label: "Projects", values: { starter: "3", team: "Unlimited" } },
]}
/>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | — | Comparison heading and accessible table caption. |
description | string | — | Optional introduction. |
plans | ComparisonPlan[] | — | Columns with a stable id and name. |
features | ComparisonFeature[] | — | Rows with a stable id, label, and values keyed by plan id. |
density | "comfortable" | "compact" | "comfortable" | Spacing preset. |
className | string | — | Extra section classes. |
why it's built this way
Engineering Notes
Uses a native HTML table with scoped column and row headers instead of visually aligned divs, because comparison depends on preserving each value's relationship to its plan and feature for assistive technology. A min-width and horizontal overflow wrapper retain readable columns on narrow screens rather than compressing the labels into illegibility. Missing cells render a neutral dash.
how it moves, and when it doesn't
Motion Notes
The table is static and introduces no motion; comparisons benefit from stable row and column alignment rather than animated rearrangement. The mobile overflow is directly scrollable and does not rely on motion or hover to reveal values, so reduced-motion settings do not alter its behavior.