Skip to content

Block 48 of 297

Pricing Toggle

Plan or membership tiers with a monthly/annual switch built from radios and CSS :has(), plus a visible savings note.

Puck key
PricingToggleBlock
Export
pricingToggleBlock
React component
<PricingToggle />
Path
components/puck/pricing-toggle-block.tsx
Dependencies
None
License
MIT

About this block

When to use it, how to write for it, and what to change in the code.

What it's for

Up to four plan or membership cards under a monthly and yearly switch. The switch is a pair of radio buttons, and CSS swaps the prices with no JavaScript. Yearly prices show as a per-month figure beside the struck-through monthly price. Cards stack on phones, and two plans sit side by side from tablet width.

  • Makerspace, gym or studio memberships offered monthly or yearly
  • Subscription or software plans with a yearly discount
  • Recurring donor levels where yearly giving earns a lower monthly rate
Writing the content
  • Enter Annual price, per month as the monthly equivalent, and put the yearly total in Annual billing note.
  • Monthly prices always show "Billed monthly, cancel any time". That line is in code, so change it if it isn't true.
  • Both billing options share one Button link per tier; add something like ?plan= if checkout needs to tell them apart.
  • Make sure the Savings note matches your actual prices. Feature one tier at most and give it a Badge.
Accessibility
  • The switch is a fieldset with a hidden "Billing period" legend and native radios, so arrow keys work (WCAG 2.1.1).
  • The struck-through price has hidden "was" text, so the comparison is spoken.
  • Prices for the unselected period use display: none, so screen readers hear only the current price.
Customizing the code
  • The swap relies on the group/billing wrapper class and the showMonthly and showAnnual constants; keep them together.
  • The featured card is bg-indigo-700 and the selected pill bg-neutral-950.

Editor fields

What content editors see in the P1 sidebar when they select this block.

  • Headingtext
  • Heading levelselect
  • Introtextarea
  • Monthly option labeltext
  • Annual option labeltext
  • Savings notetext
  • Selected at firstradio
  • Price suffixtext
  • Tiersarray
  • Footnotetextarea