Veil UI
Components

Comparison Table

A feature matrix comparing plans with check marks.

Installation

$ npx veil-ui@latest add comparison-table

Usage

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

<ComparisonTable
  plans={[{ name: "Starter", price: "$0" }, { name: "Team", price: "$24" }]}
  rows={[
    { feature: "Projects", values: ["3", "Unlimited"] },
    { feature: "SSO", values: [false, true] },
  ]}
/>;

Examples

Basic

FeatureStarter$0Team$24EnterpriseCustom
Projects3UnlimitedUnlimited
SSONot includedNot includedIncluded
Audit logNot includedIncludedIncluded
Priority supportNot includedIncludedIncluded

Caption

Plan comparison
FeatureMonthlyYearly
BillingMonthlyAnnual
DiscountNot includedIncluded

API reference

The package exports comparison-table along with its composable parts. It forwards standard attributes to its root element; see the examples above for the component-specific props.

Accessibility

  • Content uses semantic HTML — lists are lists, tables are tables and metadata uses a definition list.
  • Interactive elements are real buttons or links with visible focus states.
  • Images require meaningful alt text; icons used decoratively are aria-hidden.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add comparison-table --framework vue or switch the framework in components.json.

<script setup lang="ts">
import { Check, Minus } from "lucide-vue-next";
import { computed } from "vue";

import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@/components/ui/table";
import { cn } from "@/lib/utils";

import type { ComparisonPlan, ComparisonRow } from "./types";

const props = defineProps<{
  plans: ComparisonPlan[];
  rows: ComparisonRow[];
  caption?: string;
  class?: string;
}>();

const matrix = computed(() =>
  props.rows.map((row) => ({
    feature: row.feature,
    values: props.plans.map((_, index) => row.values[index]),
  })),
);
</script>

<template>
  <Table data-slot="comparison-table" :class="cn(props.class)">
    <caption v-if="caption" class="mb-3 text-left text-sm font-medium">
      {{ caption }}
    </caption>
    <TableHeader>
      <TableRow>
        <TableHead>Feature</TableHead>
        <TableHead v-for="plan in plans" :key="plan.name" class="text-center">
          <span class="block font-medium text-foreground">{{ plan.name }}</span>
          <span
            v-if="plan.price"
            class="block text-xs font-normal text-muted-foreground"
          >
            {{ plan.price }}
          </span>
        </TableHead>
      </TableRow>
    </TableHeader>
    <TableBody>
      <TableRow v-for="row in matrix" :key="row.feature">
        <TableCell class="font-medium">{{ row.feature }}</TableCell>
        <TableCell
          v-for="(plan, index) in plans"
          :key="plan.name"
          class="text-center"
        >
          <template v-if="typeof row.values[index] === 'boolean'">
            <span
              v-if="row.values[index]"
              class="inline-flex items-center gap-1 text-emerald-600 dark:text-emerald-400"
            >
              <Check class="size-4" aria-hidden="true" />
              <span class="sr-only">Included</span>
            </span>
            <span v-else class="inline-flex items-center gap-1 text-muted-foreground">
              <Minus class="size-4" aria-hidden="true" />
              <span class="sr-only">Not included</span>
            </span>
          </template>
          <template v-else>{{ row.values[index] }}</template>
        </TableCell>
      </TableRow>
    </TableBody>
  </Table>
</template>

On this page