Reference

Data attributes and states

On this page

AndOr widgets say what they are doing with data-* attributes and state classes. Style these, not the words. The words change with the cart and the language. The attributes do not.

Caution A hidden widget or part carries both the hidden attribute and an inline display: none. Never write a rule that forces it back on, such as andor-badge { display: block }. It would bring back an expired sale.

On every widget host

Attribute Values Meaning
data-andor-widget badge, countdown, offer, goal, tiers, bundle, bxgy, gift the widget type
data-andor-widget-id a block id, or pasted which block drew it; pasted for a one-line tag
data-andor-state active, hidden, applied written by the events script on each pass
  • The sale price host, <andor-price>, carries no data-andor-widget. It is still a host.
  • On the offers list, each row is a host, not the <andor-offers> wrapper.
  • applied means the host has an --applied class. Only the badge reaches it.
  • data-andor-state is a styling hook. Do not read it back as truth.

Progress: data-andor-progress

Widgets that move through a deal’s steps write their progress on the host as data-andor-progress:

Value Meaning
locked the cart has not reached the deal yet
unlocked the cart reached a step, or the deal can be claimed now
won the top step is reached, or checkout applied the deal
off the cart earned it and another discount won instead

The goal bar uses locked, unlocked and won. The bundle card uses locked and won. The Buy X Get Y and gift banners use all four.

andor-bundle[data-andor-progress="won"] {
  --andor-bundle-text-color: #1f5f3a;
  --andor-bundle-fill-color: #1f5f3a;
}
CSS

Per widget

Each widget’s own attributes and states are on its page:

Style states with colour, not size

Widgets printed by JavaScript first print a skeleton at the finished size. Some states are written only on the drawn widget. If you change a size per state, the page moves when the widget is drawn. Change colors per state, and sizes through the widget’s custom properties.

Next steps

Last updated

Was this page helpful?

No

Questions? Email andor@backtrackhq.com or use the chat in the app.