Skip to main content

Styling your Referral Campaign

Style your referral campaign with custom CSS, including where to add it, built-in snippets, Developer mode in the preview and every campaign class.

Written by Kris James

Use the Custom CSS editor to change how your referral campaign looks beyond the colours and layout options on the Design tab. This article lists every class the campaign uses, the snippets built into the editor, and the developer tools in the campaign preview.

Referral Campaigns are available on the Growth plan and above.


Where to Add Custom CSS

  1. In Mage Loyalty, click Referrals in the left menu and open Referral Campaigns.

  2. Find your campaign in the list, open its actions menu and click Edit.

  3. In the campaign editor, open the Advanced tab.

  4. Type your CSS into the Custom CSS box. The preview on the right updates as you type.

  5. Save your changes.

Use Format to tidy your CSS and Expand to give the editor more room while you work.

Your custom CSS applies everywhere the campaign appears: the campaign block on your storefront page and the site-wide popup. You do not need to add it twice.


Design Settings and Custom CSS

Colours and sizes from the Design tab are applied as inline styles on elements such as the card, title, subtitle, inputs, buttons, URL box and footer. Inline styles win over normal CSS rules, so a rule like .mage-referral-campaign__button { background-color: red; } will not change a button that already has a colour set on the Design tab.

You have two options:

  • Add !important to the properties you want to override.

  • Tick Disable inline styling at the bottom of the Design tab. The design colours and sizes are then no longer applied, and your CSS controls the look completely.


Autocomplete and Snippets

Type a full stop followed by a few letters, for example .mage, and the editor suggests matching campaign classes.

Snippets insert a ready-made block of CSS with placeholder values. Type the snippet name on an empty line (not inside a rule) and pick it from the list. Press Tab to move between the placeholder values.

Snippet

What it inserts

card

Background colour, border radius and padding for .mage-referral-campaign__card

typography

Font size, weight and colour for .mage-referral-campaign__title, plus font size, colour and opacity for .mage-referral-campaign__subtitle

button

Background colour, text colour, border colour and border radius for .mage-referral-campaign__button

input

Background colour, border colour, border radius and text colour for .mage-referral-campaign__input

social-buttons

Border radius and padding for .mage-referral-campaign__social-btn, plus a background colour for each platform button (X, Facebook, WhatsApp, Email, SMS)

url-box

Background, border colour and border radius for .mage-referral-campaign__url-box, plus background, text colour and border radius for .mage-referral-campaign__copy-btn

code-box

Background, border colour and border radius for .mage-referral-campaign__code-box, plus font size and colour for .mage-referral-campaign__code

footer

Font size, colour and opacity for .mage-referral-campaign__footer

two-column

Padding and background colour for .mage-referral-campaign__column-form, plus background size and position for .mage-referral-campaign__column-media

popup

Backdrop colour for .mage-referral-popup__overlay, maximum width for .mage-referral-popup__content, and background and text colour for .mage-referral-popup__close

email-dialog

Rules for the older email dialog classes (.mage-referral-campaign__email-dialog-input and .mage-referral-campaign__email-dialog-send). These classes are no longer used, so see the note below.

stack-layout

Border radius, padding, font size and weight for .mage-referral-campaign__social-btn--stack and .mage-referral-campaign__copy-btn--stack. The copy button rule does not currently apply, because the block does not use that class.

The email-dialog snippet and the __email-dialog-* suggestions in autocomplete target classes that no longer exist on the page, so rules written with them have no effect. To style the email share form, use the __overlay-* classes listed under Email Share and Referral Stats Overlays below.


Inspecting Classes in the Preview

The campaign preview has built-in developer tools for finding class names. Click the Developer button in the top-left corner of the preview to show them.

Developer mode

  • In the Developer menu, click the first button (Developer mode) to turn it on.

  • Hover over any part of the campaign to see its campaign classes.

  • Click an element to pin it. Press Esc to unpin, or press it again to turn Developer mode off.

  • Press C to copy an empty CSS rule that targets the selected element, ready to paste into the editor.

  • Press a number key from 1 to 9 to copy that class from the list, or click a class to copy it.

Classes in view

In the Developer menu, click the second button (Classes in view) to see every campaign class on the current preview, grouped by component. Click a class to scroll to it in the preview, or use the copy button to copy its selector.

Use the page state tabs above the preview (Advocate Signup, Advocate Share, Friend Claim, Friend Reward) to inspect each view. On Advocate Share, click the email button or the referrals link inside the preview to open the email share form or the referral stats.


Page States

The campaign shows one of four views depending on who is visiting. Each view uses a different set of classes inside the card.

Page state

What it shows

Advocate Signup

The sign-up or log-in form: __form, __input, __checkbox, __terms-link and __button

Advocate Share

The advocate's referral link and share buttons, wrapped in __share, plus the optional referrals link in the footer

Friend Claim

The friend's email form: __form, __input, __checkbox, __terms-link and __button

Friend Reward

The friend's discount code, wrapped in __reward, with a copy button and a shop button

Every class in this table starts with .mage-referral-campaign, for example .mage-referral-campaign__share.


CSS Class Reference

Block and layout

Class

What it styles

.mage-referral-campaign

Root container of the campaign block

.mage-referral-campaign--align-start

Root modifier when the card is aligned left (Card layout only)

.mage-referral-campaign--align-end

Root modifier when the card is aligned right (Card layout only)

.mage-referral-campaign--has-bg

Root modifier when a background image is set (Card layout only)

.mage-referral-campaign--two-column

Root modifier for the Two Columns layout (chosen under Layout on the Design tab)

.mage-referral-campaign__mobile-media

Panel that shows the background image above the card on mobile. Hidden on larger screens.

.mage-referral-campaign__loading

Placeholder shown while the campaign loads

.mage-referral-campaign__card

Content card that holds the title, form or share tools, and footer

Card content

Class

What it styles

.mage-referral-campaign__title

Heading

.mage-referral-campaign__subtitle

Text under the heading

.mage-referral-campaign__error

Error message

.mage-referral-campaign__form

Form wrapper on Advocate Signup and Friend Claim

.mage-referral-campaign__input

Name and email inputs

.mage-referral-campaign__checkbox

Checkbox row for terms and email marketing opt-in

.mage-referral-campaign__terms-link

Terms and conditions link

.mage-referral-campaign__button

Main action button

.mage-referral-campaign__footer

Footer text

.mage-referral-campaign__footer-sep

Separator between the footer text and the referrals link

.mage-referral-campaign__stats-link

"View my referrals" link on Advocate Share. Only shown to logged-in customers.

Advocate Share

Class

What it styles

.mage-referral-campaign__share

Wrapper around the referral link and share buttons

.mage-referral-campaign__url-box

Box that holds the referral link and copy button

.mage-referral-campaign__url

Referral link text field

.mage-referral-campaign__copy-btn

Copy button (also used for the discount code on Friend Reward)

.mage-referral-campaign__social

Row of share buttons

.mage-referral-campaign__social-btn

Every share button

.mage-referral-campaign__social-btn--twitter

X (Twitter) button

.mage-referral-campaign__social-btn--facebook

Facebook button

.mage-referral-campaign__social-btn--whatsapp

WhatsApp button

.mage-referral-campaign__social-btn--email

Email button, which opens the email share form

.mage-referral-campaign__social-btn--sms

SMS button

Stack layout modifiers

Added on top of the normal classes when Share buttons layout is set to Stack on the Advocate Share page.

Class

What it styles

.mage-referral-campaign__share--stack

Share wrapper in stack layout

.mage-referral-campaign__url-box--stack

Referral link box in stack layout

.mage-referral-campaign__social--stack

Share buttons arranged in a column

.mage-referral-campaign__social-btn--stack

Full-width pill-shaped share buttons

In Stack layout, target the copy button with .mage-referral-campaign__url-box--stack .mage-referral-campaign__copy-btn.

Friend Reward

Class

What it styles

.mage-referral-campaign__reward

Wrapper around the discount code and shop button

.mage-referral-campaign__code-box

Box that holds the discount code and copy button

.mage-referral-campaign__code

Discount code text

Two Columns layout

Class

What it styles

.mage-referral-campaign__columns

Wrapper around the two columns

.mage-referral-campaign__column-form

Left column that holds the card

.mage-referral-campaign__column-media

Right column that shows the image or column colour

Email Share and Referral Stats Overlays

The email share form and the referral stats open inside the campaign. In the Card layout they replace the card content. In the Two Columns layout they open as a panel over the image column. Both use a fixed white background and dark text, and only pick up the button colour from the Design tab.

Class

What it styles

.mage-referral-campaign__overlay-host

White container for the overlay in the Card layout

.mage-referral-campaign__overlay-host--closing

Added to the container while it fades out

.mage-referral-campaign__overlay-panel

Panel for the overlay in the Two Columns layout

.mage-referral-campaign__overlay-panel--closing

Added to the panel while it fades out

.mage-referral-campaign__overlay

Overlay content wrapper

.mage-referral-campaign__overlay-close

Close button

.mage-referral-campaign__overlay-title

Overlay heading

.mage-referral-campaign__overlay-field

Label and input pair in the email form

.mage-referral-campaign__overlay-label

Field label

.mage-referral-campaign__overlay-input

To and subject inputs

.mage-referral-campaign__overlay-textarea

Additional note field

.mage-referral-campaign__overlay-send

Send button (also has .mage-referral-campaign__button)

.mage-referral-campaign__overlay-error

Error message

.mage-referral-campaign__overlay-success

Success message

Referral stats

Class

What it styles

.mage-referral-campaign__stats-loading

Loading message

.mage-referral-campaign__stats-summary

Row showing the referred and completed totals

.mage-referral-campaign__stats-summary-item

Each total

.mage-referral-campaign__stats-empty

Message shown when there are no referrals yet

.mage-referral-campaign__stats-list

List of referrals

.mage-referral-campaign__stats-row

Each referral

.mage-referral-campaign__stats-row-main

Email and date group

.mage-referral-campaign__stats-email

Friend email

.mage-referral-campaign__stats-date

Referral date

.mage-referral-campaign__stats-status

Status text

.mage-referral-campaign__stats-status--invited

Status modifier for Invited

.mage-referral-campaign__stats-status--pending

Status modifier for Pending

.mage-referral-campaign__stats-status--completed

Status modifier for Completed

The status modifiers have no styling by default, so you can use them to build your own status badges:

.mage-referral-campaign__stats-status--completed {  color: #16a34a;}.mage-referral-campaign__stats-status--pending {  color: #d97706;}

Site-wide popup

Class

What it styles

.mage-referral-popup__overlay

Full-screen dark backdrop behind the popup

.mage-referral-popup__content

Popup content area that holds the campaign

.mage-referral-popup__close

Round close button in the top-right corner

Inside the popup the campaign root loses its minimum height and padding, so target .mage-referral-popup__content .mage-referral-campaign for popup-only changes.


Mobile Layout

Below 768px wide:

  • The Two Columns layout stacks. The image column moves to the top (at least 250px tall) and the form column sits below it.

  • In the Card layout with a background image, the image is removed from behind the card and shown in .mage-referral-campaign__mobile-media above it instead, and the card loses its rounded corners.

  • The email share and referral stats panel in the Two Columns layout covers the whole block instead of just the image column.

To target the same screens in your own CSS:

@media (max-width: 767px) {  .mage-referral-campaign__title {    font-size: 24px;  }}

Common Mistakes to Avoid

Your CSS has no effect on colours. The Design tab colours are inline styles. Add !important to your rule, or tick Disable inline styling on the Design tab.

Styling the email form with the old email-dialog classes. Those classes are no longer on the page. Use the __overlay-* classes instead.

Writing selectors that are too broad. Custom CSS is added to the whole page, so a rule like button { } also changes your theme's buttons. Always start selectors with a campaign class such as .mage-referral-campaign.


Troubleshooting

My CSS shows in the preview but not on my store

  • Check that you saved the campaign after editing.

  • Refresh the storefront page, and check it in a private window in case your browser is showing an old version.

  • Use your browser tools to check whether a theme rule with a stronger selector is overriding yours.

I cannot find a class for an element

  • Click Developer in the preview, turn on Developer mode, and hover over the element.

  • Switch to the right page state tab first. Share buttons only appear on Advocate Share, and the discount code only appears on Friend Reward.

  • Share buttons only appear for the sharing options that are turned on for your store.

The popup looks different from the campaign page

  • The popup removes the block's minimum height and padding. Use .mage-referral-popup__content .mage-referral-campaign for popup-only rules.

Did this answer your question?