Free gift banner element
Updated Sep 18, 20263 min read
On this page (8)
<hype-free-gift-banner> renders a Gift with Purchase campaign on a product page: a promo header the shopper can open, a message, and a row per eligible gift with its variant picker and a claim button. It reads the cart from the SDK and re-renders on every cart change, so a gift's row turns from locked to claimable the moment the offer unlocks.
Placement
The theme editor block is Hype: Gift Banner. In custom code, place the tag inside your product template:
<hype-free-gift-banner id="hype-gift-banner" identifier="YOUR_APP_BLOCK_ID" {% if request.design_mode %}design-mode="true"{% endif %}></hype-free-gift-banner>It must sit on a product page. The controller reads the product handle from the page URL and renders nothing when there is none, so the element is invisible on the cart page, the home page and collection pages. It is also invisible when the current product is not covered by the campaign's gift rule, and when the campaign has no gifts.
Attributes
| Attribute | Required | Default | Description |
|---|---|---|---|
identifier | Yes | "" | The campaign block's App block ID |
design-mode | No | false | true renders a placeholder gift for styling in the theme editor |
Everything else — the promo bar title and icon, the message for each gift state, the claim button labels, the gift badge — comes from the block's settings in the Hype admin.
Two layouts
The block's settings decide which structure you are styling:
- With the promo bar on, the element renders a clickable header plus a collapsible body holding the message and gift rows. This is the default.
- With the promo bar off, the header disappears and the gift rows render directly in the container.
A second setting controls whether the header can collapse at all. When it cannot, clicking the header does nothing and no chevron renders.
CSS custom properties
| Property | Default | Applies to |
|---|---|---|
--font-size | 14px | Header, message and gift titles. The subtitle is 4px smaller and the description 2px smaller. |
--font-weight | bold | Header title, message and gift titles |
--header-bg-color | #000 | Header background and the claim button background |
--header-text-color | #fff | Header text and claim button text |
--body-bg-color | #F7F7F7 | Expanded body background |
--body-text-color | #000 | Message, gift title, subtitle and description |
--product-bg-color | #fff from the theme block | Background of each gift row and of the free label |
--max-width | 100% | Outer width |
--border-radius | 10px | Header and body corners |
--header-bg-color and --header-text-color also paint the claim button, so a dark header gives you a dark button unless you override the button through its part.
Parts
| Part | Element |
|---|---|
container | Outer container, in both layouts |
header | Clickable promo header |
header-content | Icon and title inside the header |
arrow-icon | Expand/collapse chevron |
gift-item-container | Collapsible body |
gift-banner-message | The message line above the gifts |
gift-item-wrapper | The <hype-free-gift-item> itself |
Each gift row forwards these parts:
| Part | Element |
|---|---|
banner-gift-item | Gift row |
banner-gift-image | Image container |
banner-gift-details | Text column |
banner-gift-status | Subtitle line |
banner-gift-title | Product title |
banner-claim-button | Claim button |
banner-free-label | Badge over the image |
The banner does not forward a description part. The cart progress bar forwards the same row with tier- prefixes and does include tier-gift-description.
Gift state
The gift row reflects its state onto itself:
| Attribute | Present when |
|---|---|
is-added-to-cart | The gift is already in the cart |
is-disabled | The offer is not unlocked yet, or a claim is in flight |
is-loading | This gift's claim request is running |
Style them directly:
#hype-gift-banner hype-free-gift-item[is-added-to-cart] { opacity: 0.6; }#hype-gift-banner hype-free-gift-item[is-disabled] { pointer-events: none; filter: grayscale(100%);}Or read them:
const claimed = document.querySelectorAll( '#hype-gift-banner hype-free-gift-item[is-added-to-cart]',)console.log(`${claimed.length} gift(s) claimed`)When a shopper claims a gift, Hype adds the line and dispatches hype:item-added-to-cart on document. Gifts that Hype adds or removes on its own — because the cart crossed or fell below the offer's threshold — dispatch hype:free-gifts-added and hype:free-gifts-removed instead.
Styling example
<style> #hype-gift-banner { --header-bg-color: #111827; --header-text-color: #ffffff; --body-bg-color: #ffffff; --product-bg-color: #f9fafb; --font-size: 14px; --border-radius: 8px; --max-width: 100%; } #hype-gift-banner::part(header) { letter-spacing: 0.04em; } #hype-gift-banner::part(gift-banner-message) { justify-content: flex-start; padding-inline: 8px; } #hype-gift-banner::part(banner-claim-button) { background: #16a34a; border-radius: 999px; } #hype-gift-banner::part(banner-free-label) { text-transform: uppercase; }</style>Gift rows carry a fixed drop shadow and an 8px corner radius of their own; override them through ::part(banner-gift-item).
Related
Was this article helpful?
Related articles
Still stuck?
Ask a follow-up and we'll see it came from “Free gift banner element”.
Opens chat with your question and a link to this article.