Skip to content
Docs

Sale Badge

DKL Sale Badge component

DKL Sale Badge component

<dkl-sale-badge> is a theme-agnostic sale badge — e.g. Save up to 20% or Save up to $5.00. It’s a light-DOM component: the label is the element’s own text content (no shadow DOM), and the host element itself is styled as the badge. That keeps it dropping cleanly into a product card and painting from server-rendered markup.

The amount comes from the sale itself. A badge is built for one sale discount in Discount Kit → Components, and on the storefront it reads that sale’s row out of the shop’s offer index — so it shows what that sale takes off this product, and nothing else’s discount can raise it.

Where the sale doesn’t reach the product, the badge renders nothing. It also hides itself when the shopper moves to a variant the sale refuses: one that’s already marked down when the sale skips marked-down lines, or one whose metafield-sourced value can’t be read.

  • Real text. The badge is plain, server-rendered text (e.g. “Save up to 20%”) — not an image or a CSS background — so screen readers read it verbatim and it scales with browser zoom and text-size settings.
  • No empty announcements. When nothing applies, the component hides the host entirely rather than leaving an empty element for assistive tech to encounter.
  • Contrast. Because the badge colours are merchant-configurable, keep --dkl-badge-color and --dkl-badge-background at a sufficient contrast ratio when restyling.