Web Component
A web component is the <dkl-discount-badge> tag written directly into your theme’s Liquid.
On a product page it needs zero attributes — it paints from the page product’s carrier
and renders the badge.
On a product page, add the <dkl-discount-badge> web component — it renders the primary product’s badge:
<dkl-discount-badge></dkl-discount-badge>Reacting to changes
Section titled “Reacting to changes”<dkl-discount-badge> emits no events — it re-renders its own text in place on a variant
change. To run your own code when the badge updates, watch the element with a
MutationObserver — see React to badge updates in the examples below.
Examples
Section titled “Examples”For the full list of data-* attributes you can set, see
Styling & Data Attributes.
<dkl-discount-badge data-discount-type="highest"></dkl-discount-badge><dkl-discount-badge data-discount-type="highest" data-label="[amount] off today" style=" --dkl-badge-background: #111; --dkl-badge-color: #fff; --dkl-badge-radius: 999px; --dkl-badge-font-size: 0.85rem; "></dkl-discount-badge>// <dkl-discount-badge> emits no events — it re-renders its own text in place// on variant change. Observe each badge to react to those updates.// Handles any number of badges on the page.document.querySelectorAll('dkl-discount-badge').forEach((badge) => { new MutationObserver(() => { console.log('Badge now reads:', badge.textContent.trim()) }).observe(badge, { childList: true, characterData: true, subtree: true })})Next steps
Section titled “Next steps”Styling & Data AttributesEvery data-* attribute and --dkl-badge-* token.
App blockThe no-code, theme-editor placement.