Playground

Pricing block

Plan cards with a monthly and yearly switch.

  • Built on native elements
  • A section named by its title; plans are a list, each with a heading one level below the title.
  • The billing switch is a named radio group operable with arrow keys.
  • Prices are plain text next to their period, never colour alone; the popular plan carries a text badge.
  • Styles in one file: container.css

Import

import '@monoline/css';
import {BlockPricing} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add block-pricing

Usage

import {BlockPricing} from '@monoline/react';

<BlockPricing
  title="Simple pricing"
  description="Switch to yearly for two months free."
  tiers={[
    {name: 'Free', description: 'For trying it out.', price: {monthly: '$0', yearly: '$0'}, features: ['One project', 'Community support'], ctaLabel: 'Start free', href: '#'},
    {name: 'Team', description: 'For small teams.', price: {monthly: '$12', yearly: '$120'}, features: ['Unlimited projects', 'Email support', 'Shared themes'], ctaLabel: 'Choose Team', highlighted: true},
    {name: 'Scale', description: 'For larger groups.', price: {monthly: '$48', yearly: '$480'}, features: ['Everything in Team', 'Single sign-on', 'Priority support'], ctaLabel: 'Talk to us', href: '#'},
  ]}
/>

Examples

Three plans

Props

BlockPricingProps

PropTypeDefaultDescription
title requiredReactNode–Section heading shown above the tiers.
descriptionReactNode–Optional muted line under the heading.
tiers requiredPricingTier[]–The plans to compare, each with a name, monthly and yearly price, features and a call to action.
defaultIntervalPricingInterval'monthly'Start on yearly billing.
labelsPartial<{ monthly: string; yearly: string; switcher: string; period: Record<PricingInterval, string>; highlight: string; }>–Overrides for the built-in English texts (Monthly, Yearly, Billing period, Popular, / month, / year); use it to translate.
renderLinkRenderLink–Renders a tier's link (the ones with `href`), so a client router can handle the click. Default a plain `<a href>`.
onSelect((tier: PricingTier, interval: PricingInterval) => void)–Called when a tier's button (one without `href`) is pressed.
headingLevel1 | 2 | 3 | 4 | 52Outline level of the section title, 1 to 5. Default 2; each tier name is one level lower.

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

AttributeStylesheet
[data-state="on"]segmented-control.css
[data-highlighted]block-pricing.css

CSS classes

ClassStylesheet
.containercontainer.css
.container-fullcontainer.css
.container-pagecontainer.css
.container-textcontainer.css
.headingheading.css
.heading-displayheading.css
.heading-lgheading.css
.heading-mdheading.css
.heading-smheading.css
.heading-xlheading.css
.texttext.css
.text-accenttext.css
.text-dangertext.css
.text-fulltext.css
.text-lgtext.css
.text-mdtext.css
.text-mutedtext.css
.text-oktext.css
.text-smtext.css
.text-successtext.css
.text-truncatetext.css
.text-warningtext.css
.text-xstext.css
.btn02-buttons.css
.btn-block02-buttons.css
.btn-danger02-buttons.css
.btn-ghost02-buttons.css
.btn-lg02-buttons.css
.btn-line02-buttons.css
.btn-sm02-buttons.css
.btn-solid02-buttons.css
.badge05-marks.css
.badge-accent05-marks.css
.badge-solid05-marks.css
.check05-marks.css
.check-fail05-marks.css
.check-pass05-marks.css
.dot05-marks.css
.heat-005-marks.css
.heat-105-marks.css
.heat-205-marks.css
.heat-305-marks.css
.heat-405-marks.css
.kbd05-marks.css
.key-hints05-marks.css
.swatch05-marks.css
.segmentsegmented-control.css
.segmentedsegmented-control.css
.block-pricingblock-pricing.css
.block-pricing-headblock-pricing.css
.block-pricing-tiersblock-pricing.css
.block-tierblock-pricing.css
.block-tier-amountblock-pricing.css
.block-tier-featuresblock-pricing.css
.block-tier-headblock-pricing.css
.block-tier-periodblock-pricing.css
.block-tier-priceblock-pricing.css
.segmentedblock-pricing.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.container {
  border-color: var(--accent);
}
.container[data-state="on"] {
  background: var(--wash);
}

Accessibility

  • A section named by its title; plans are a list, each with a heading one level below the title.
  • The billing switch is a named radio group operable with arrow keys.
  • Prices are plain text next to their period, never colour alone; the popular plan carries a text badge.