> ## 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.

# Header wishlist link

> A wishlist link in the header with a live count of saved items, from the loveful-wishlist snippet, loveful-header-icon or your own icon.

Three ways to put a wishlist link with a count in the header, from least to most code. All of them update the moment the shopper saves or removes something, in any tab.

## Option 1: the snippet

With the [`loveful-wishlist` snippet](https://docs.loveful.app/developers/guides/card-hearts) created, render it in the header file (`header.liquid` in most themes), next to the cart icon:

```liquid sections/header.liquid theme={null}
{% render 'loveful-wishlist', type: 'count' %}
```

**type** `string` *required*

`count`

**url** `string`

Where the link goes. Defaults to the wishlist page the snippet was copied with.

```liquid theme={null}
{% render 'loveful-wishlist', type: 'count', url: '/pages/saved' %}
```

It renders a link with a heart drawn in CSS and a [`<loveful-count>`](https://docs.loveful.app/developers/web-components#loveful-count) badge, counted in Liquid for the signed-in shopper so it's right on first paint:

```html theme={null}
<a href="/pages/wishlist" class="loveful-header-link" data-loveful-snippet="1" aria-label="Wishlist">
  <loveful-count hidden>0</loveful-count>
</a>
```

The badge is hidden while the list is empty and shows `99+` above 99. It takes the header's text colour, with the number in the opposite colour. Restyle it with:

```css theme={null}
.loveful-header-link {
  --loveful-icon-size: 20px;
  --loveful-header-count-bg: #c8102e;
  --loveful-header-count-fg: #fff;
  --loveful-header-count-size: 0.625rem;
}
```

> [!NOTE]
>
> The snippet's `aria-label` starts as the English "Wishlist". Once the page loads, Loveful sets it from the `loveful.header_label` translation, so it's read aloud in the shopper's language. Change the wording on **Settings › Translations**.

## Option 2: loveful-header-icon

A ready-made heart and badge, with no snippet needed. Wrap it in a link:

```liquid theme={null}
<a href="{{ pages.wishlist.url | default: '/pages/wishlist' }}" class="header__icon">
  <loveful-header-icon></loveful-header-icon>
</a>
```

Leave the element empty: Loveful fills it with the icon and a [`<loveful-count>`](https://docs.loveful.app/developers/web-components#loveful-count), and labels it with the `loveful.header_label` translation unless it already has an `aria-label`. Its size and colours are `--loveful-icon-size`, `--loveful-icon-color`, `--loveful-count-bg` and `--loveful-count-fg`. See [`<loveful-header-icon>`](https://docs.loveful.app/developers/web-components#loveful-header-icon).

## Option 3: the theme's own icon

To match the theme's other header icons exactly, use its own icon markup and add a `<loveful-count>`:

```liquid sections/header.liquid theme={null}
{%- assign loveful_count = customer.metafields['app--1234567'].refs_1.value | size -%}
<a href="/pages/wishlist" class="header__icon header__icon--wishlist link focus-inset">
  {% render 'icon-heart' %}
  <span class="visually-hidden">Wishlist</span>
  <div class="cart-count-bubble" {% if loveful_count == 0 %}hidden{% endif %}>
    <loveful-count data-cap="9">{{ loveful_count }}</loveful-count>
  </div>
</a>
```

Replace `app--1234567` with the namespace in your `loveful-wishlist` snippet. Here the theme's bubble wraps the count, so hide the bubble too when the count hides:

```css theme={null}
.cart-count-bubble:has(> loveful-count[hidden]) {
  display: none;
}
```

`<loveful-count>` sets `hidden` and `data-count` on itself; see [`<loveful-count>`](https://docs.loveful.app/developers/web-components#loveful-count) for `data-cap` and `data-hide-at-zero`.

## A count anywhere else

The same element works in a mobile menu, a drawer or the wishlist page's heading:

```html theme={null}
<h1>My wishlist (<loveful-count data-hide-at-zero="false">0</loveful-count>)</h1>
```

To drive your own badge from script instead, read `window.loveful.state.size` on the bus's `item_added`, `item_removed` and `list_cleared` events. See [React to saves](https://docs.loveful.app/developers/guides/react-to-saves.md).


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