Calm motion: animations on this site only fade, with no movement
Wishlist button
A heart that saves a product, with a count and a status message
Lets a buyer keep a product for later. Put it on a product card or a product page.
Basic
vue
<template>
<div style="display: flex; gap: 12px; align-items: center">
<BlessWishlistButton v-model="saved" name="USB microphone" :count />
<BlessWishlistButton :model-value="true" name="Foam panels" />
</div>
</template>
<script setup lang="ts">
import { computed, ref } from "vue";
import { BlessWishlistButton } from "blessing-ui";
const saved = ref(false);
// the count from the server, plus this reader
const count = computed(() => 41 + (saved.value ? 1 : 0));
</script>v-modelis true when the product is saved.nameis the name of the product. The button is a toggle named "Save … to the wishlist", so screen readers hear its state as pressed or not pressed.- A saved heart is filled, and a heart that is not saved is an outline. The shape changes, not only the color.
- After a click, a hidden status line says that the product is in or out of the wishlist. A page load says nothing.
countshows how many people saved the product. Give the new count after a click.- If the reader saves the product, the heart grows for a moment. Under reduced motion, it does not move.
- Change the words with
labelsor a label pack: the functionssave,added, andremoved.
Usage
ts
import { BlessWishlistButton } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
name* | string | — | the name of the product, for the name of the button |
count | number | — | how many people saved it |
labels | Partial<{ save: (name: string) => string; added: (name: string) => string; removed: (name: string) => string; }> | — | |
modelValue | boolean | false |
Events
| Name | Payload | Description |
|---|---|---|
update:modelValue | [value: boolean] |