Pricing Billing Switch
This article documents
Pricing Billing Switch Pro
A heading with a Monthly / Yearly switch and three plan cards, the middle one highlighted.
Requires: nothing. The switching is done with native Bricks Interactions and a few lines of CSS on the section’s class, so the template needs no companion script and no library.
How it works#
- Each
Tabis a button with three click interactions: setdata-billingon the section (tomonthlyoryearly), setaria-selectedto false on both tabs, then to true on itself. Open the element’s Interactions tab to see them. - Every price and period exists twice: one element carries the class
bx-when-monthly, the otherbx-when-yearly. The section shows the ones that match itsdata-billingand hides the others. The section starts onmonthly(its Attributes); change it toyearlyto open on yearly prices. - The chosen tab gets a white background, dark text and a small shadow; the change takes 0.15s.
What you replace#
| In the structure panel | What to do |
|---|---|
Title, Description | Your heading and text |
Tab - Monthly, Tab - Yearly | The labels in Label; leave the interactions as they are |
Plan - ... (3) | The badge, Price - monthly and Price - yearly, the two periods, the features and the button |
The free plan keeps its period text but hides it (Visibility: hidden) so the three cards line up. To add a plan, duplicate a card: its prices already carry the right classes.
Layout and breakpoints#
The description and switch sit on one row above 767px and stack at 767px. The three cards share the row and stretch to the same height, with the buttons pushed to the bottom; at 767px they stack. The title goes from 48px to 30px and the prices from 48px to 36px at 991px.
Classes#
Global classes with typed settings: bxp04-tab, bxp04-card, bxp04-badge, bxp04-price, bxp04-period, bxp04-separator, bxp04-body, bxp04-list, bxp04-item, bxp04-check, bxp04-btn-primary, bxp04-btn-outline. The section class bsfy-p04 holds only what Bricks has no control for: the monthly/yearly visibility, the chosen tab, the focus rings and reduced motion.
Reduced motion and without JavaScript#
With reduced motion the tab and button transitions are off. Without JavaScript the monthly prices show and the switch does nothing.