CSS variables, classes and events

This reference is for theme developers. It lists the CSS variables, class names, data attributes and browser events that Sol: Upsell keeps stable, so you can style the offers and react to them from your theme. Names listed here are not renamed after release. New ones may be added.

Before you start

CSS variables

Set them in your theme CSS on .sol-upsell or on any parent, for example :root.

Variable Default Used for
--sol-upsell-gap 12px Spacing inside rows and panels
--sol-upsell-radius 8px Cards, buttons and panels (not the popup window, the variant select or badges)
--sol-upsell-line 14% of the text color Borders and separators
--sol-upsell-soft 5% of the text color Panel tint and image placeholder
--sol-upsell-btn-bg Theme's Add to cart background Solid button fill, button borders (and button text in the outline style), selected tier border, checkboxes and radio buttons, progress bar and reached milestones
--sol-upsell-btn-fg Theme's Add to cart text color Text on the solid button and the icon of reached milestones
--sol-upsell-badge-bg Text color Border and text of the discount badge
--sol-upsell-sale Text color Current price (discounted price, or the regular price when there is no discount)
--sol-upsell-image-size 64px Product image in list rows and popup rows (add-on uses 75% of it)
--sol-upsell-columns As many as fit Max columns of the grid and Bought together layouts
--sol-upsell-mt, --sol-upsell-mb 18px (12px on the cart block) Space above and below. Not used by popups or cart goal bars.

In a row narrower than 480 px (600 px with four cards, 760 px with five), the Bought together layout is always an even two-column grid, so --sol-upsell-columns: 1 is not applied there.

The older --su-* names are kept, but the app sets them itself and can override yours. Use the --sol-upsell-* names. A --sol-upsell-* variable wins over the matching --su-* one and over Settings > Design. A value set in the theme editor block settings is applied directly on the block and wins over theme CSS.

Data attributes

Attribute Value
data-sol-upsell On the root of the product page block
data-sol-upsell-cart On the root of the cart block and of the cart drawer offers
data-sol-upsell-goal On the root of the cart goal bars (cart page and cart drawer)
data-layout list, grid, fbt (Bought together), addon, vol (volume), carousel (cart drawer), popup, goal
data-placement pdp, cart, drawer, atc (popup after adding), cartopen (popup when cart opens), pdpnote
data-offer-id The offer's ID, once an offer is drawn. It never holds a name, email or customer ID.
data-align, data-hide-heading Set from the block settings

Classes

Every element the app draws has a sol-upsell__<name> class, next to its older su-<name> class. Use the sol-upsell__ ones in your CSS.

Class Element
sol-upsell__h Heading
sol-upsell__body, __row, __card Body, list row, card
sol-upsell__im, __nm, __pr Image, name, price
sol-upsell__was Old price
sol-upsell__now Current price
sol-upsell__pill Discount badge
sol-upsell__btn, __btn-solid Button, and the solid button
sol-upsell__select, __cb, __cbl Variant select, checkbox, checkbox label
sol-upsell__fbt, __fbt-items, __fbt-sum Bought together layout, its items, its total
sol-upsell__grid, __addons, __addon Grid and add-on layouts
sol-upsell__tiers, __tier, __radio Volume tiers
sol-upsell__car, __slide, __car-track, __car-arrow, __car-dots Cart drawer carousel
sol-upsell__goal, __goal-msg, __goal-track, __goal-fill, __ms Cart goal bar and milestones
sol-upsell__err Add-to-cart error message
sol-upsell__status, __cart-link, __plus, __pop-box, __pop-t Status line, "View cart" link, plus sign, popup box and popup title

State classes such as su-on, su-off, su-error and su-ready are not mirrored. Use aria-* attributes or the su-* class for those. The classes stay on the elements when the offer redraws, for example when a shopper picks a tier.

Style a part

The app's own styles use two or more class names, and in places such as the cart drawer they load after your theme's CSS. A single sol-upsell__ class is weaker than that. Start rules that target a part with body .sol-upsell. A few app styles are more specific still, so add !important if a declaration does not apply.

/* Two-line product names, full-width buttons on small screens */
body .sol-upsell .sol-upsell__nm { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 480px) { body .sol-upsell .sol-upsell__btn { width: 100%; } }

/* Cart drawer only */
.sol-upsell[data-placement="drawer"] { --sol-upsell-mb: 0; }

To hide a part, scope the rule to the offer in the same way. Do not move the app's elements around.

body .sol-upsell .sol-upsell__pill { display: none; }

Events

The app sends browser CustomEvents that bubble, so document.addEventListener receives them. The detail holds IDs, fixed values and counts only. It never holds cart contents, customer data, email, address or tokens. Events are notifications: the app never runs code from them.

Event When it fires detail
sol-upsell:ready Once per block (and per popup) when its first offer is drawn. Not on later redraws. offerId, placement, layout
sol-upsell:added After the shopper's own add to cart from an offer succeeded, and after the cart goal adds its free gift automatically. offerId, placement, itemCount, su
sol-upsell:error An add to cart from an offer failed, or a cart goal change the shopper started failed. offerId, placement, code: add_failed, or remove_failed when a cart goal could not remove a gift

For the automatic free gift, offerId and placement are null. A gift removal sends no sol-upsell:added. itemCount is the cart's item count after the add, or null if unknown. Read offerId and placement instead of su, which is kept for the app's own statistics.

document.addEventListener('sol-upsell:ready', (e) => {
  console.log('Offer drawn', e.detail.offerId, e.detail.placement, e.detail.layout);
});

document.addEventListener('sol-upsell:added', (e) => {
  document.querySelector('#my-cart-count').textContent = e.detail.itemCount ?? '';
});

document.addEventListener('sol-upsell:error', (e) => {
  console.warn('Add failed', e.detail.offerId, e.detail.code);
});

Other event names that start with sol-upsell: are internal signals between the app's own scripts. They may change, so do not use them.

The app also sends your theme's own cart event for the theme families it knows, so the theme can refresh its cart.

Related articles

← Customize how offers look in your theme