> ## Documentation Index
> Fetch the complete documentation index at: https://docs.loveful.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Hearts on your product cards

> Add a save heart to the product cards in collections and search, with the loveful-wishlist snippet or your own markup.

A heart on each product card lets shoppers save from collections, search results and anywhere else the theme shows cards. App blocks can't go inside a product card, so the heart comes from the `loveful-wishlist` snippet, which you create once in the theme's code.

## 1. Create the snippet

Loveful can't write theme files, so the snippet is pasted by hand:

1. In Loveful, go to **Settings > Storefront** and click **Copy snippet** under **Product cards and header**.
2. In the theme's **Edit code**, add a snippet named `loveful-wishlist`, paste and save.

The copy already has your store's metafield namespace and wishlist page filled in. Settings > Storefront shows **Added** once Loveful finds it in the live theme.

## 2. Render it in the card

Find the theme's product card snippet (`card-product.liquid` in Dawn and most Shopify themes) and render the heart inside the element that wraps the card's image:

```liquid snippets/card-product.liquid theme={null}
<div class="card__media">
  {{ card_product.featured_media | image_url: width: 600 | image_tag }}
  {% render 'loveful-wishlist', type: 'heart', product: card_product %}
</div>
```

**type** `string` *required*

`heart`

**product** `product` *required*

The card's product: whatever variable the card snippet uses for it (`card_product` in Dawn).

> [!NOTE]
>
> The heart is positioned absolutely over the image's top right corner, so the element that contains it needs `position: relative`. Most themes already set it on the card's media wrapper for their own badges.

## What it renders

```html theme={null}
<loveful-button
  appearance="icon"
  data-loveful-snippet="1"
  data-vid="44012345678901"
  data-pid="8012345678901"
  data-handle="linen-shirt"
  role="button"
  tabindex="0"
  aria-pressed="false"
></loveful-button>
```

A [`<loveful-button>`](https://docs.loveful.app/developers/web-components#loveful-button) in [card heart mode](https://docs.loveful.app/developers/web-components.md#card-heart-mode):

* It saves the product's selected or first available variant.
* It shows as saved when **any** variant of the product is saved, and a click on a saved heart removes every saved variant of the product.
* Its click doesn't open the card's link.
* `aria-pressed` and `data-saved` are worked out in Liquid from the signed-in customer's saved items, so the heart is right on first paint. A guest's hearts fill in once the script runs.
* The heart is drawn in CSS, not in the markup, so its look can change without re-pasting the snippet.

Cards added later, by a filter, infinite scroll or a quick view, work with no extra code.

## Position, size and colour

The merchant sets these in the theme editor under **App embeds > Loveful > Product card heart** (see [Save button](https://docs.loveful.app/user-guide/storefront/save-button.md#heart-settings)): position (top right, top left or in line), size, colour, colour when saved, and the white circle behind it.

In CSS, set the [card heart variables](https://docs.loveful.app/developers/css-variables.md#product-card-heart-snippet):

```css theme={null}
:root {
  --loveful-card-size: 18px;
  --loveful-card-color: #6b6b6b;
  --loveful-card-saved-color: #c8102e;
  --loveful-card-bg: transparent;
  --loveful-card-heart-offset: 0.75rem;
}
```

To move it, override the position on the element:

```css theme={null}
.card__media loveful-button[appearance="icon"] {
  top: auto;
  bottom: 0.5rem;
}
```

## Writing the markup yourself

Write the element directly when the snippet's markup doesn't suit the card, for example to save a particular variant or to put the heart beside the title instead of over the image:

```liquid theme={null}
<h3 class="card__heading">
  {{ card_product.title }}
  <loveful-button
    appearance="icon"
    data-vid="{{ card_product.selected_or_first_available_variant.id }}"
    data-pid="{{ card_product.id }}"
    data-handle="{{ card_product.handle }}"
    role="button"
    tabindex="0"
    aria-pressed="false"
    style="position: relative; inset: auto"
  ></loveful-button>
</h3>
```

Without the snippet's saved check, a signed-in shopper's heart shows as unsaved until the script runs. Every attribute is on [`<loveful-button>`](https://docs.loveful.app/developers/web-components#loveful-button).

## Snippet versions

Every element the snippet renders carries `data-loveful-snippet="<version>"`; the current version is `1`. Settings > Storefront shows **Update needed** when the theme's copy is older: copy the snippet again and paste it over the old one. The render lines in the theme don't change.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.