Blocks Design System

Plan comparison

Every feature of three plans in one Table: rows grouped under Collaboration, Security and Support, check and dash icons that read as “Included” and “Not included”, limits as text, and a row of Button links at the foot. The header row and the feature column stay in place while the table scrolls inside its TableContainer.

Compare plans

Prices are per seat per month, billed yearly. Scroll sideways to see every plan.

Features by plan
Feature
Starter$8
Team$20Most popular
EnterpriseCustom
Collaboration
Projects5Unlimited
Editors per project3Unlimited
Shared map layersNot includedIncluded
Review and sign‑offNot includedIncluded
Guest accessNot includedUnlimited
Security
Two‑factor authenticationIncludedIncluded
SAML single sign‑onNot includedIncluded
Audit logNot includedUnlimited, exportable
Data residency (US, EU, CA)Not includedIncluded
Support
Help center and emailIncludedIncluded
First response2 business days4 hours
Priority chatNot includedIncluded
Named success managerNot includedIncluded
Choose a planStart free trialContact sales
Source · recipes/plan-comparison.tsx
recipes/plan-comparison.tsx
import {
  Badge,
  BodySmall,
  Button,
  Heading,
  Stack,
  Table,
  TableBody,
  TableCell,
  TableContainer,
  TableHead,
  TableHeader,
  TableRow,
  Text,
} from '@blocks/design-system'
import { Check, Minus } from 'lucide-react'
import styles from './plan-comparison.module.css'

const plans = [
  { name: 'Starter', price: '$8', cta: 'Start free trial', href: '#plan-comparison-starter' },
  { name: 'Team', price: '$20', cta: 'Start free trial', href: '#plan-comparison-team', popular: true },
  { name: 'Enterprise', price: 'Custom', cta: 'Contact sales', href: '#plan-comparison-sales' },
]

// The popular plan's column is tinted from header to call to action.
const tint = (plan?: { popular?: boolean }) => (plan?.popular ? styles.popular : undefined)

/** `true` and `false` render as icons with text; strings are limits. Feature names
 * use a non-breaking hyphen (U+2011) so a narrow column never splits "sign-off". */
type Value = boolean | string

const groups: { name: string; rows: { feature: string; values: [Value, Value, Value] }[] }[] = [
  {
    name: 'Collaboration',
    rows: [
      { feature: 'Projects', values: ['5', 'Unlimited', 'Unlimited'] },
      { feature: 'Editors per project', values: ['3', '25', 'Unlimited'] },
      { feature: 'Shared map layers', values: [false, true, true] },
      { feature: 'Review and sign‑off', values: [false, true, true] },
      { feature: 'Guest access', values: [false, '10 guests', 'Unlimited'] },
    ],
  },
  {
    name: 'Security',
    rows: [
      { feature: 'Two‑factor authentication', values: [true, true, true] },
      { feature: 'SAML single sign‑on', values: [false, false, true] },
      { feature: 'Audit log', values: [false, '30 days', 'Unlimited, exportable'] },
      { feature: 'Data residency (US, EU, CA)', values: [false, false, true] },
    ],
  },
  {
    name: 'Support',
    rows: [
      { feature: 'Help center and email', values: [true, true, true] },
      { feature: 'First response', values: ['2 business days', '1 business day', '4 hours'] },
      { feature: 'Priority chat', values: [false, true, true] },
      { feature: 'Named success manager', values: [false, false, true] },
    ],
  },
]

// A full comparison as one table. Each group is its own <tbody> with a
// rowgroup header; the header row and feature column stay put while the
// table scrolls inside its region.
export default function PlanComparison() {
  return (
    <Stack as="section" gap="md" aria-labelledby="plan-comparison-title" dangerouslySetClassName={styles.root}>
      <Stack gap="xs">
        <Heading as="h2" id="plan-comparison-title" fontSize="xl">
          Compare plans
        </Heading>
        <BodySmall margin="none" color="text-muted">
          Prices are per seat per month, billed yearly.
          <span className={styles.scrollHint}> Scroll sideways to see every plan.</span>
        </BodySmall>
      </Stack>

      {/* The frame draws a fade at the right edge while there's more to scroll. */}
      <div className={styles.frame}>
        <TableContainer tabIndex={0} role="region" aria-labelledby="plan-comparison-caption" dangerouslySetClassName={styles.scroller}>
          <Table dangerouslySetClassName={styles.table}>
            <caption id="plan-comparison-caption" className={styles.visuallyHidden}>
              Features by plan
            </caption>
            <TableHeader>
              <TableRow>
                <TableHead scope="col">Feature</TableHead>
                {plans.map((plan) => (
                  <TableHead key={plan.name} scope="col" dangerouslySetClassName={tint(plan)}>
                    <Stack gap="none" align="center">
                      <Text fontSize="sm" fontWeight="semibold" color="text">
                        {plan.name}
                      </Text>
                      <Text fontSize="xs" fontWeight="body">
                        {plan.price}
                      </Text>
                      {plan.popular && <Badge tone="accent">Most popular</Badge>}
                    </Stack>
                  </TableHead>
                ))}
              </TableRow>
            </TableHeader>
            {groups.map((group) => (
              <TableBody key={group.name}>
                <TableRow>
                  <TableHead scope="rowgroup" colSpan={plans.length + 1} dangerouslySetClassName={styles.group}>
                    <span>{group.name}</span>
                  </TableHead>
                </TableRow>
                {group.rows.map((row) => (
                  <TableRow key={row.feature}>
                    <TableHead scope="row">{row.feature}</TableHead>
                    {row.values.map((value, index) => (
                      <TableCell key={plans[index]?.name} dangerouslySetClassName={tint(plans[index])}>
                        <PlanValue value={value} />
                      </TableCell>
                    ))}
                  </TableRow>
                ))}
              </TableBody>
            ))}
            <tfoot>
              <TableRow>
                <TableHead scope="row">
                  <span className={styles.visuallyHidden}>Choose a plan</span>
                </TableHead>
                {plans.map((plan) => (
                  <TableCell key={plan.name} dangerouslySetClassName={tint(plan)}>
                    <Button
                      as="a"
                      href={plan.href}
                      size="sm"
                      variant={plan.popular ? 'primary' : 'base'}
                      aria-label={`${plan.cta}: ${plan.name}`}
                    >
                      {plan.cta}
                    </Button>
                  </TableCell>
                ))}
              </TableRow>
            </tfoot>
          </Table>
        </TableContainer>
      </div>
    </Stack>
  )
}

function PlanValue({ value }: { value: Value }) {
  if (typeof value === 'string') return <>{value}</>
  return value ? (
    <>
      <Check aria-hidden className={styles.included} />
      <span className={styles.visuallyHidden}>Included</span>
    </>
  ) : (
    <>
      <Minus aria-hidden className={styles.excluded} />
      <span className={styles.visuallyHidden}>Not included</span>
    </>
  )
}
Compare plans

How it works

  • Each group is its own TableBody that opens with a TableHead of scope="rowgroup" spanning the row, and every feature name is a TableHead with scope="row". A screen reader announces a cell as, for example, “Security, SAML single sign-on, Enterprise, Included”.
  • The icons are hidden from assistive technology and paired with visually hidden text, so the table never relies on a check mark or a color alone.
  • The TableContainer is a focusable, labelled region that scrolls. The popular plan’s column is tinted from its header down to its button, so the recommendation reads in every row and not only in the header Badge. The app’s CSS makes the header cells position: sticky at the top and the feature column sticky at the left, with the corner cell above both; the table switches to border-collapse: separate so the sticky cells keep their borders.
  • On a narrow container the feature column slims to 8rem, the region gets a capped height so the sticky header earns its keep, a line of text says to scroll sideways, and a fade at the right edge shows there is more. Where scroll-driven animations are supported, the fade leaves once you reach the end. The page itself never scrolls sideways. Each call to action’s accessible name includes its plan.
  • It is a Server Component: no state, and the parts are imported by name.

App-owned CSS

recipes/plan-comparison.module.css
.root {
  container-type: inline-size;
}

/* The table scrolls inside its region. */
.scroller {
  /* Positioned, so visually hidden text scrolls with the content instead of widening the page. */
  position: relative;
  overflow: auto;
  border: var(--ds-border-width-sm) solid var(--ds-color-border-subtle);
  border-radius: var(--ds-border-radius-md);
}

.frame {
  position: relative;
}

.scrollHint {
  display: none;
}

.table {
  min-width: 34rem;
  border-collapse: separate;
  border-spacing: 0;

  & th,
  & td {
    border-bottom: var(--ds-border-width-sm) solid var(--ds-color-border-subtle);
  }

  & td {
    padding-block: var(--ds-space-md);
    text-align: center;
    color: var(--ds-color-text);
  }

  & tbody th[scope="row"] {
    font-size: var(--ds-font-size-sm);
    font-weight: var(--ds-font-weight-body);
    color: var(--ds-color-text);
    white-space: normal;
  }

  /* Sticky header row… */
  & thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding-block: var(--ds-space-md);
    text-align: center;
    vertical-align: bottom;
    background-color: var(--ds-color-bg-subtle);
  }

  /* …and sticky first column, with the corner cell above both. */
  & th:first-child:not([colspan]) {
    position: sticky;
    left: 0;
    z-index: 1;
    width: 11rem;
    text-align: left;
    background-color: var(--ds-color-bg);
    box-shadow: inset calc(var(--ds-border-width-sm) * -1) 0 var(--ds-color-border-subtle);
  }

  & thead th:first-child {
    z-index: 2;
    background-color: var(--ds-color-bg-subtle);
  }

  & tfoot td,
  & tfoot th {
    padding-block: var(--ds-space-lg);
    border-bottom: none;
  }
}

/* The popular plan's column, tinted top to bottom. Opaque, because the
   header cells are sticky and content scrolls beneath them. */
.table .popular {
  background-color: color-mix(in srgb, var(--ds-color-accent-subtle) 50%, var(--ds-color-bg));
}

.table thead .popular {
  background-color: var(--ds-color-accent-subtle);
}

/* Group headings span the row; the label stays in view while scrolling. */
.table .group {
  padding-top: var(--ds-space-lg);
  font-size: var(--ds-font-size-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background-color: var(--ds-color-bg);

  & span {
    position: sticky;
    left: var(--ds-space-md);
  }
}

/* Narrow: a slimmer feature column, a capped height so the sticky header
   matters, a hint, and a fade at the right edge that says there's more. */
@container (max-width: 36rem) {
  .scroller {
    max-height: 26rem;
  }

  .table {
    min-width: 30rem;
  }

  .table th:first-child:not([colspan]) {
    width: 8rem;
  }

  .scrollHint {
    display: inline;
  }

  .frame::after {
    content: "";
    position: absolute;
    top: var(--ds-border-width-sm);
    right: var(--ds-border-width-sm);
    bottom: var(--ds-border-width-sm);
    width: var(--ds-space-xl);
    pointer-events: none;
    background: linear-gradient(to right, transparent, color-mix(in srgb, var(--ds-color-text) 14%, transparent));
    border-radius: 0 var(--ds-border-radius-md) var(--ds-border-radius-md) 0;
  }

  /* Where scroll-driven animations exist, the fade leaves at the end. */
  @supports (animation-timeline: scroll()) {
    .frame {
      timeline-scope: --plans;
    }

    .scroller {
      scroll-timeline: --plans x;
    }

    .frame::after {
      animation: fade-at-end linear both;
      animation-timeline: --plans;
    }
  }
}

@keyframes fade-at-end {
  90% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

.included,
.excluded {
  width: var(--ds-icon-size-sm);
  height: var(--ds-icon-size-sm);
  vertical-align: middle;
}

.included {
  color: var(--ds-color-success-text);
}

.excluded {
  color: var(--ds-color-text-muted);
}

.visuallyHidden {
  position: absolute;
  width: var(--ds-space-xxs);
  height: var(--ds-space-xxs);
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}