How to update the Subscription Widget using CSS
You can apply custom CSS to the Subscription Widget using the widget editor to customize its appearance fully. Recharge injects these styles directly into the widget’s root element, allowing you to see your changes reflected immediately.
This guide explains how to use CSS to update styling for the Subscription Widget.
How it works
The Subscription Widget uses a Shadow DOM to isolate its internal styles from the rest of the page. This means you cannot style internal widget elements directly using normal CSS selectors.
Recharge exposes specific components using the part attribute, which enables styling on widget elements. These are part values, and you can target them using custom CSS in the widget editor. See Available CSS classes for a full list of part values you can use.
You can use the ::part()
syntax to apply styles to these elements from the widget editor.
Example
To change the color of the Learn More link:
::part(rc-learn-more\_\_trigger) {
color: red;
}
Styling elements outside the Shadow DOM
Some widget elements, like the outer container or shared DOM elements, are not inside the Shadow DOM. You can style these elements using regular CSS selectors without ::part().
Example
.rc-content-wrap {
padding: 16px;
}
Edit the widget with custom CSS
You can add custom CSS directly within the widget editor:
- Click Cross-Sell & Upsell from the merchant portal and select Subscription widget.
- Click Create widget from template.
- Starter plan merchants can choose the Standard widget
- Pro and Custom plan merchants can choose the Standard widget or they can A/B test multiple widgets
- Click the Subscription widget node and select Customize subscription widget.
- Select Edit styles.
- Paste your CSS into the Advanced: enter custom CSS textbox.
- Press Done to save your changes.
Tip:
Recharge hosts Custom CSS in the widget editor, ensuring you can A/B test different widget customizations for each of your A/B test paths.
Available CSS classes
Use the CSS classes below to customize the subscription widget:
Element Description | CSS Class (Part Value) |
---|---|
Benefits List | rc-benefits__list |
Benefits Image | rc-benefits__image |
Design Mode Banner | rc-design-mode-banner |
Design Mode Banner Content | rc-design-mode-banner__content |
Design Mode Banner Close | rc-design-mode-banner__close |
Design Mode Banner Icon | rc-design-mode-banner__icon |
Learn More Section | rc-learn-more |
Learn More Trigger | rc-learn-more__trigger |
Learn More Trigger (Compact) | rc-learn-more__trigger-compact |
Learn More Modal | rc-learn-more-modal |
Learn More Modal Content | rc-learn-more-modal__content |
Learn More Modal Close Button | rc-learn-more-modal__close-button |
Learn More Modal Content Body | rc-learn-more-modal__content-body |
Learn More Modal Container | rc-learn-more-modal__container |
Loading Wrapper | rc-loading |
Loading Icon | rc-loading__icon |
Drawbacks Section | rc-drawbacks |
Plans Button | rc-plans-button |
Selected Plan Button | rc-plans-button__selected |
Plan Button Group | rc-plans-button-group |
Plan Button List | rc-plans-button-list |
Plans Label | rc-plans__label |
Plans Radio Button | rc-plans-radio-button |
Plans Discount Label | rc-plans-button__discount |
Plans Interval Label | rc-plans-button__interval |
Plans Dropdown | rc-plans-dropdown |
Plans Select | rc-plans-select |
One-time Section | rc-purchase-option__onetime |
Subscription Section | rc-purchase-option__subscription |
Currently Selected Section | rc-purchase-option__selected |
One-time Purchase Option | rc-purchase-option |
One-time Option Label | rc-purchase-option__label |
One-time Option Selector | rc-purchase-option__selector |
One-time Option Input | rc-purchase-option__input |
One-time Checked Indicator | rc-purchase-option__checked-indicator |
One-time Price | rc-purchase-option__price |
One-time Prices Wrapper | rc-purchase-option__prices |
One-time Sub-container | rc-purchase-option__sub-container |
Subscription Purchase Option | rc-purchase-option |
Subscription Option Label | rc-purchase-option__label |
Subscription Option Selector | rc-purchase-option__selector |
Subscription Option Input | rc-purchase-option__input |
Subscription Checked Indicator | rc-purchase-option__checked-indicator |
Subscription Sub-container | rc-purchase-option__sub-container |
Subscription Original Price | rc-purchase-option__original-price |
Subscription Unit Price | rc-purchase-option__unit-price |
Subscription Prices Wrapper | rc-purchase-option__prices |
Subscription Discounted Price | rc-purchase-option__discounted-price |
Subscription Badge | rc-purchase-option__badge |
Prepaid Plan Title | rc-prepaid-plan__title |
Content Wrapper | rc-content-wrap |
Widget Root | rc-widget__root |
CSS examples
Review the examples below for ideas on how you can customize the appearance of your subscription widget using CSS:
Action | CSS |
---|---|
Puts a border around the benefits | css<br>::part(rc-benefits__list) {<br> border: 1px solid black;<br> padding: 10px;<br>} |
Makes price and selector text red | css<br>::part(rc-purchase-option__label) {<br> color: red;<br>} |
Adds a border to the entire widget | css<br>::part(rc-content-wrap) {<br> border: solid 1px blue;<br>} |
Makes benefits to frequency green and bordered | css<br>::part(rc-purchase-option__sub-container) {<br> border: solid 5px green;<br>} |
Makes discounted price larger | css<br>::part(rc-purchase-option__discounted-price) {<br> font-size: 20px;<br>} |
Re-orders strikethrough and subscription price location | css<br>::part(rc-purchase-option__prices) {<br> display: flex;<br> flex-direction: row-reverse;<br> gap: 20px;<br>} |
Change color of checkmarks in benefits | css<br>::part(rc-benefits__list) {<br> --rc-widget-bullet-icon-image-color: blue;<br>} |
Reversed order of objects in Subscription box | css<br>::part(rc-purchase-option__sub-container) {<br> display: flex;<br> flex-direction: column-reverse;<br>} |
Put Subscription and Onetime side-by-side | css<br>::part(rc-content-wrap) {<br> display: flex;<br> gap: 10px;<br>} |
Updated 5 days ago