Step 1 — Add the component
Use <ooo-wl-wishlist-button> on product pages, collection cards, or other product sections. You control the HTML and CSS; the component handles wishlist actions and updates the button state.
<ooo-wl-wishlist-button product-id="{{ product.id }}" handle="{{ product.handle }}" loading>
<button type="button">
<span class="ooo-wl-wishlist-button-add">Add to wishlist</span>
<span class="ooo-wl-wishlist-button-remove">Remove from wishlist</span>
</button>
<p>You already have <span></span> variants in your wishlist.</p>
</ooo-wl-wishlist-button>
Step 2 — Configure the attributes
| Attribute | Required | Purpose |
|---|---|---|
product-id |
Yes | Shopify product ID. |
handle |
Yes | Product handle, used to fetch product information. |
loading |
Yes, initially | Marks the loading state so you can hide the button until it is ready. |
variant-id |
No | Specific variant ID to track. When provided, update this attribute yourself whenever the selected variant changes. |
If you omit variant-id, the component detects the selected variant from the URL or product form. To manage it yourself, add variant-id="{{ variant_id }}" to the opening tag and keep its value synchronized with your variant selector.
Step 3 — Style the button
The component has no shadow DOM or encapsulated styles. Add CSS to your theme to control its appearance. Keep selectors scoped to the component so they do not affect other buttons.
ooo-wl-wishlist-button[loading] {
visibility: hidden;
}
ooo-wl-wishlist-button button[aria-checked="true"] .ooo-wl-wishlist-button-add,
ooo-wl-wishlist-button button[aria-checked="false"] .ooo-wl-wishlist-button-remove {
display: none;
}
ooo-wl-wishlist-button p {
display: none;
}
ooo-wl-wishlist-button[show-variant-warning="true"] p {
display: block;
}
ooo-wl-wishlist-button[show-variant-warning="true"] p span::before {
counter-reset: count var(--ooo-wl-variants-added-count);
content: counter(count);
}
Component state reference
The component updates these values automatically. Use them in your styles rather than setting them manually.
| Attribute or variable | Location | Purpose |
|---|---|---|
aria-checked |
Inner <button>
|
Indicates whether the product or variant is in the wishlist (true or false). |
aria-busy |
Inner <button>
|
Indicates that the button is loading. |
show-variant-warning |
<ooo-wl-wishlist-button> |
Indicates whether to show a warning about another saved variant of the same product. |
--ooo-wl-variants-added-count |
CSS variable on the component | Number of variants of this product already in the wishlist. |
Display a variant warning
Keep the following message inside the component to show how many variants are already saved:
<p>You already have <span></span> variants in your wishlist.</p>
The CSS above displays the message when show-variant-warning="true" and inserts the count into the <span> using the CSS variable.
Check your integration
- Check the loading, add, and remove states on each template where you use the component.
- Change the selected variant and confirm the button follows it. If you set
variant-id, update it manually. - Check your styles on product pages, collection cards, and mobile layouts.
For a wishlist badge, see Add a wishlist counter to your theme. For custom JavaScript actions, see JavaScript API.