Hype Discounts

Product banner element

Updated Sep 18, 20263 min read

On this page (7)

<hype-product-banner> renders a single-line promotional banner on a product page — an icon and a message announcing the discount that applies to the product being viewed. It supports a solid background color or one of nine named gradients.

Placement

The theme editor block is Hype: Product Banner. In custom code, place the tag in your product template, usually just above or below the price:

<hype-product-banner  id="hype-banner"  identifier="YOUR_APP_BLOCK_ID"  background="--magic-gradient"  {% if request.design_mode %}design-mode="true"{% endif %}></hype-product-banner>

The banner renders only on product pages, only for Multi Products Discount and Order Discount campaigns, and only when the product in the URL matches one of the campaign's discount rules. Anywhere else it renders nothing. It also re-checks itself when the page's URL changes without a reload, so themes that swap products in place keep showing the right message.

Attributes

AttributeRequiredDefaultDescription
identifierYes""The campaign block's App block ID
backgroundNosolidsolid uses --background-color. Any other value is treated as a CSS custom property name and used as the background.
design-modeNofalsetrue renders a placeholder banner for styling in the theme editor

The message and icon come from the block's settings in the Hype admin. The message accepts two variables, written without spaces inside the braces:

VariableRenders
{{discount}}The discount that applies to this product, formatted — for example 20% or $5.00
{{discount_code}}The campaign's discount code

Named gradients

Pass one of these names to background:

NameGradient
--magic-gradientBlue → purple → red → orange
--electric-horizonCyan → violet → pink → amber
--neon-sunsetIndigo → magenta → red → gold
--tropical-burstBlue → violet → pink → orange
--cyber-fusionTeal → blue → purple → coral
--vibrant-dawnGreen → cyan → pink → yellow
--laser-pulseMint → blue → purple → red
--digital-candyCyan → orchid → red → amber
--future-glowTeal → indigo → magenta → yellow

All nine are four-stop linear-gradients at 108 degrees. The same nine names are available on the announcement bar and the toast, through their background-style attribute.

You are not limited to the nine. background accepts any custom property name, so define your own and pass it:

:root {  --brand-fade: linear-gradient(90deg, #0f766e, #14b8a6);}
<hype-product-banner identifier="YOUR_APP_BLOCK_ID" background="--brand-fade"></hype-product-banner>

To change one of the nine built-in gradients, redefine it on the element itself rather than on :root — the element declares its own value for those nine names:

#hype-banner { --neon-sunset: linear-gradient(90deg, #111827, #4b5563); }

CSS custom properties

PropertyDefaultApplies to
--background-color#000Background, when background is solid
--text-color#fffMessage text and the icon
--font-size14px from the theme blockMessage text. The icon is drawn 4px larger.
--font-weightnormalMessage text
--border-radius0pxCorners
--text-aligncenterHorizontal alignment. Takes a flexbox alignment value: center or flex-start.
--inline-padding15px from the theme blockLeft and right padding
--block-padding8px from the theme blockTop and bottom padding
--box-shadow0 2px 8px rgba(0, 0, 0, 0.15)Shadow. Set none to remove it.
--max-width100%Outer width

--font-size, --inline-padding and --block-padding have no unit in the element's own fallbacks, because the theme block always supplies one. When you place the element by hand, always write the unit: --font-size: 14px.

--text-align is passed straight to justify-content, so left and right do nothing. Use flex-start, center or flex-end.

Parts

PartElement
product-bannerOuter banner, carries the background, padding, radius and shadow
content-wrapFlex row holding the icon and the message
messageThe <p> with the message text

Styling example

<style>  #hype-banner {    --background-color: #0f172a;    --text-color: #f8fafc;    --font-size: 15px;    --font-weight: bold;    --border-radius: 8px;    --inline-padding: 20px;    --block-padding: 12px;    --box-shadow: none;    --text-align: flex-start;    --max-width: 100%;  }  #hype-banner::part(product-banner) {    border: 1px solid #1e293b;  }  #hype-banner::part(message) {    text-transform: uppercase;    letter-spacing: 0.06em;  }</style><hype-product-banner id="hype-banner" identifier="YOUR_APP_BLOCK_ID"></hype-product-banner>

Leave background off, or set it to solid, whenever you are styling with --background-color. A gradient name always wins over that variable.

Related articles

Still stuck?

Ask a follow-up and we'll see it came from “Product banner element”.

Opens chat with your question and a link to this article.