This pattern uses data attributes to switch content when the billing toggle is clicked. No code editing required.
The toggle switches the data-billing attribute between "annual" and "monthly". Elements with matching data attributes automatically update their text content.
Select the Pricing Toggle Section element → Cmd+K
| Attribute | Values | Description |
|---|---|---|
data-billing |
annual or monthly |
Which prices show on page load |
Select any price (e.g., “$10/mth”) → Cmd+K
| Attribute | Example | Description |
|---|---|---|
data-annual |
$10/mth |
Shown when Annual is selected |
data-monthly |
$15/mth |
Shown when Monthly is selected |
Select “Billed annually.” text → Cmd+K
| Attribute | Example | Description |
|---|---|---|
data-annual |
Billed annually. |
Shown when Annual is selected |
data-monthly |
Billed monthly. |
Shown when Monthly is selected |
data-annual to your annual price (e.g., $99/yr)data-monthly to your monthly price (e.g., $12/mth)Any text element can toggle by adding both data attributes:
data-annual="Save 20%"
data-monthly="Pay as you go"
The script will automatically swap the text when the toggle is clicked.
data-billing on section)