Pricing Table

Free

Subscription plans as cards or a feature-by-plan comparison table, with a monthly / annual toggle. Each plan carries one monthly figure: the annual price, the invoice actually charged, the cash saved and the "save at least N %" are derived from it and one discount, so the page can never advertise a saving it does not give. The highlighted plan is badged in text, quote-only and free plans are first-class, and CTA links are checked for a safe scheme.

</>sv-pricing-table pricingplanspricing tablesubscriptionbillingannualsaascomparisontiers

Complexity tier: Interactive The primitive bar, plus: its async states are declared — none is an answer — it has a keyboard model and restores focus, and any destructive action it offers can be undone.

import { SvPricingTableComponent } from '@styloviz/commerce/pricing-table';

Demo & usage

Basic usage

Usage example — open the gallery for the full interactive demo.

An interactive demo for this component lives in the gallery.

Open live demo

More examples

Three tiers with an annual discount

One monthly figure per plan. `[annualDiscount]="0.2"` derives every annual figure, rounded to the precision the monthly price is quoted in — whole units for $149, cents for $9.99.

example.htmlAngular
plans: SvPricingPlan[] = [
  { id: 'starter', name: 'Starter', price: { monthly: 49 }, features: ['2 seats', 'Email support'] },
  { id: 'growth', name: 'Growth', price: { monthly: 149 }, highlighted: true, features: ['10 seats', 'API access'] },
  { id: 'scale', name: 'Scale', price: { monthly: 449 }, features: ['Unlimited seats', 'SSO'] },
];

<sv-pricing-table [plans]="plans" [annualDiscount]="0.2" [(billing)]="billing" (planSelect)="checkout($event)" />

Comparison table

Rows are keyed by plan id: `true`, `false` (or missing) or a text. Rows with a `group` sit under one group heading.

example.htmlAngular
features: SvPricingFeature[] = [
  { id: 'seats', label: 'Seats', group: 'Team', values: { starter: '2', growth: '10', scale: 'Unlimited' } },
  { id: 'sso', label: 'SSO', group: 'Security', values: { scale: true } },
];

<sv-pricing-table layout="table" [plans]="plans" [features]="features" caption="Compare plans" />

A plan you quote, with a link

example.htmlAngular
{ id: 'enterprise', name: 'Enterprise', price: 'Contact sales',
  cta: { label: 'Talk to sales', href: 'mailto:sales@example.com' } }

The same arithmetic elsewhere

The helpers the table uses are exported, so a checkout summary or an upgrade dialog quotes the same figures rather than computing them a second way.

example.htmlAngular
import { svAnnualMonthly, svAnnualTotal, svAnnualSaving, svAnnualSavingPercent } from '@styloviz/commerce';

svAnnualMonthly({ monthly: 149 }, 0.2);       // 119
svAnnualTotal({ monthly: 149 }, 0.2);         // 1428
svAnnualSaving({ monthly: 149 }, 0.2);        // 360
svAnnualSavingPercent({ monthly: 149 }, 0.2); // 20

When to use

  • The pricing page of a SaaS product or a marketing site, with two to four plans.
  • An upgrade screen inside the app, where `selectedPlanId` marks the plan the account is on or is about to choose.
  • A feature-by-plan comparison under the plan cards (`layout="table"`).
  • Use `sv-price` instead for a single amount on a product, cart line or invoice.

Compare with

  • Price — Price formats one amount — a product, a cart line, an order total. Pricing Table lays out subscription plans side by side, with a billing toggle and a feature comparison.

Async states

None — this component has nothing to load, so it has no loading, empty or error state to drive.

Inputs

NameTypeDefaultDescription
plansreadonly SvPricingPlan[][]The plans, cheapest first. Plans with an empty or duplicate `id` are skipped.
featuresreadonly SvPricingFeature[][]The comparison rows, shown as the table in the `table` layout and as each card's bullet list when a plan has no `features` of its own.
billingSvPricingBilling (two-way)'monthly'Which period the prices are shown for. Two-way: `[(billing)]`; emits `billingChange`.
annualDiscountnumber0The annual discount as a fraction (`0.2` = 20 % off), used for every plan whose price has no `annual`. Outside `[0, 1)` it counts as none.
showBillingTogglebooleantrueShow the monthly / annual toggle. It is hidden anyway when no plan has a price.
currencystring'USD'ISO 4217 currency code, unless a plan sets its own.
localestringsvLocale()BCP-47 locale for prices and numbers.
layoutSvPricingTableLayout'cards'`cards` — one card per plan, stacked on phones — or a `table` comparing features.
selectedPlanIdstring | nullnullThe plan whose CTA reads "Selected" — the one your sign-up form is set to.
captionstring | nullnullThe comparison table's `<caption>`. Null uses the `pricingCaption` label ("Compare plans").
headingLevelSvPricingHeadingLevel3Heading level for each plan's name in the cards layout — match the page outline.
labelsPartial<SvPricingTableLabels>{}Per-instance text, merged over the registry's `commerce` labels.

Outputs

EventPayload typeDescription
planSelectSvPricingPlanSelectA plan's call to action was activated — its button, or its link (which also navigates).
billingChangeSvPricingBillingEmits the new `billing` whenever it changes — the output half of `[(billing)]`.

Customization & theming

  • Two layouts: `cards` (one card per plan, stacked on a phone, sized to the number of plans) and `table` (a comparison table that scrolls sideways on a phone with the feature column pinned).
  • Currency per table (`currency`) or per plan (`plan.currency`), formatted with `Intl.NumberFormat` in `locale`: whole amounts print without decimals ($149), others with the currency's own ($9.99, ¥1,200).
  • The highlighted plan, the toggle and the CTAs paint from the `primary-*` tokens, so a template that remaps primary recolours the table.
  • `caption`, `headingLevel`, `showBillingToggle` and `selectedPlanId` shape the output; every string comes from the `commerce` labels (`pricing*` keys) — `provideSvLabels(SV_COMMERCE_LABELS_DE)` or the per-instance `labels` input.
  • `svAnnualMonthly`, `svAnnualTotal`, `svAnnualSaving`, `svAnnualSavingPercent`, `svPricingHeadlineSaving` and `svFormatPlanPrice` are exported for use elsewhere.

Best practices

  • Do: Give each plan one `monthly` price and set `annualDiscount` once. Only give a plan an `annual` price when its annual rate genuinely differs from the discount.
  • Do: List plans cheapest first and highlight one plan, or none — only the first highlighted plan is emphasised.
  • Do: Keep `billing` in your own state (`[(billing)]`) so the period the visitor chose carries into checkout along with `(planSelect)`.
  • Don't: Don't type the saving into a plan's `badge` or description. The toggle's "save at least N %" is computed from the plan that saves least, so it stays true when a price changes.
  • Don't: Don't put a price into `features`. The per-month figure, the billed line and the saving already say it, and a second copy is the one that goes stale.
  • Tip: A plan with a `cta.href` renders a link — for a mailto to sales or a sign-up route. Without one it renders a button and `(planSelect)` is your hook.

Accessibility

  • The billing toggle is two native radio inputs in a `<fieldset>` with a "Billing period" legend — arrow keys move between them, no ARIA widget roles. The "save at least N %" is linked to the Annual radio with `aria-describedby`.
  • The highlighted plan is emphasised by a border and ring **and** a text badge ("Most popular"). In the cards it is read with the plan's heading; in the table it sits inside the plan's `<th scope="col">`, so it is announced with every cell of that column.
  • The comparison is a real `<table>` with a `<caption>`, `<th scope="col">` per plan, `<th scope="row">` per feature and `<th scope="rowgroup">` per group. Its scroll container is a focusable region named by the caption, so a keyboard can scroll it.
  • Included and not-included cells draw an icon and carry "Included" / "Not included" as screen-reader text — never an icon alone.
  • The visible "/ month" is hidden from screen readers and "per month" is read instead. Each CTA is described by its plan's name, so "Selected" or "Talk to sales" is never heard out of context; targets are at least 44 px tall with a visible focus ring.

Feedback on Pricing Table

Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.

Loads giscus.app and GitHub — nothing is fetched until you click.