Pricing block
Plan cards with a monthly and yearly switch.
SourceStyles source@monoline/react 0.4.0Markdown for AI toolsbeta
- 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
| Prop | Type | Default | Description |
|---|---|---|---|
title required | ReactNode | – | Section heading shown above the tiers. |
description | ReactNode | – | Optional muted line under the heading. |
tiers required | PricingTier[] | – | The plans to compare, each with a name, monthly and yearly price, features and a call to action. |
defaultInterval | PricingInterval | 'monthly' | Start on yearly billing. |
labels | Partial<{ 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. |
renderLink | RenderLink | – | 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. |
headingLevel | 1 | 2 | 3 | 4 | 5 | 2 | Outline 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.
| Attribute | Stylesheet |
|---|---|
[data-state="on"] | segmented-control.css |
[data-highlighted] | block-pricing.css |
CSS classes
| Class | Stylesheet |
|---|---|
.container | container.css |
.container-full | container.css |
.container-page | container.css |
.container-text | container.css |
.heading | heading.css |
.heading-display | heading.css |
.heading-lg | heading.css |
.heading-md | heading.css |
.heading-sm | heading.css |
.heading-xl | heading.css |
.text | text.css |
.text-accent | text.css |
.text-danger | text.css |
.text-full | text.css |
.text-lg | text.css |
.text-md | text.css |
.text-muted | text.css |
.text-ok | text.css |
.text-sm | text.css |
.text-success | text.css |
.text-truncate | text.css |
.text-warning | text.css |
.text-xs | text.css |
.btn | 02-buttons.css |
.btn-block | 02-buttons.css |
.btn-danger | 02-buttons.css |
.btn-ghost | 02-buttons.css |
.btn-lg | 02-buttons.css |
.btn-line | 02-buttons.css |
.btn-sm | 02-buttons.css |
.btn-solid | 02-buttons.css |
.badge | 05-marks.css |
.badge-accent | 05-marks.css |
.badge-solid | 05-marks.css |
.check | 05-marks.css |
.check-fail | 05-marks.css |
.check-pass | 05-marks.css |
.dot | 05-marks.css |
.heat-0 | 05-marks.css |
.heat-1 | 05-marks.css |
.heat-2 | 05-marks.css |
.heat-3 | 05-marks.css |
.heat-4 | 05-marks.css |
.kbd | 05-marks.css |
.key-hints | 05-marks.css |
.swatch | 05-marks.css |
.segment | segmented-control.css |
.segmented | segmented-control.css |
.block-pricing | block-pricing.css |
.block-pricing-head | block-pricing.css |
.block-pricing-tiers | block-pricing.css |
.block-tier | block-pricing.css |
.block-tier-amount | block-pricing.css |
.block-tier-features | block-pricing.css |
.block-tier-head | block-pricing.css |
.block-tier-period | block-pricing.css |
.block-tier-price | block-pricing.css |
.segmented | block-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.