Calm motion: animations on this site only fade, with no movement
Consent banner
A cookie consent bar with accept, reject, and a choice for each category
Asks a visitor which cookies the site can use. The visitor can accept all, keep only the needed ones, or choose each category. For other notices at the top of a page, use the banner.
Basic
Cookies on this site
We use some cookies to make the site work, and others only if you allow them. Privacy policy
vue
<template>
<div style="max-width: 560px">
<BlessConsentBanner v-model="consent" :categories position="static" policy-href="#" />
<template v-if="consent">
<BlessText as="p" size="sm" style="margin-bottom: 8px"
>Saved: {{ JSON.stringify(consent) }}</BlessText
>
<BlessButton size="sm" variant="outline" @click="consent = undefined">Ask again</BlessButton>
</template>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
import { BlessButton, BlessConsentBanner, BlessText } from "blessing-ui";
const categories = [
{
key: "needed",
label: "Needed",
description: "Keep you signed in and remember this choice.",
required: true,
},
{
key: "stats",
label: "Statistics",
description: "Count which episodes people play, with no names.",
},
{
key: "ads",
label: "Sponsors",
description: "Show sponsor messages that fit what you listen to.",
},
];
// on a real page: leave out `position`, and add `persist` to keep the choice for the next visit
const consent = ref<Record<string, boolean>>();
</script>categoriesis a list of categories. Each one has akey, alabel, an optionaldescription, and an optionalrequired. A required category is always on.v-modelis the choice, such as{ needed: true, stats: false }. It is empty until the visitor decides, and the banner shows only then.- "Accept all" turns every category on. "Only the needed ones" keeps only the required ones. "Choose" opens a switch for each category and a save button. Each choice emits
change. persistis alocalStoragekey. The choice stays for the next visit, and the banner does not show again. The banner reads the stored choice after the page loads, so it does not flash.positionisfixed(default) at the bottom of the window, orstaticin the flow of the page.policy-hrefadds a link to your privacy policy.- The banner only asks. Load your statistics or ads scripts only after
changesays yes. - The banner is a region named by its title. Change the words with
labelsor a label pack:title,message,accept,reject,customize,save,policy, andrequired.
Usage
ts
import { BlessConsentBanner } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
categories* | BlessConsentCategory[] | — | |
persist | string | — | a `localStorage` key: the choice stays for the next visit, and the banner does not show again |
position | "fixed" | "static" | "fixed" | `fixed` sits at the bottom of the window; `static` stays in the flow of the page |
policyHref | string | — | a link to the privacy policy |
labels | Partial<{ title: string; message: string; accept: string; reject: string; customize: string; save: string; policy: string; required: string; }> | — | |
modelValue | Record<string, boolean> | — | the choice for each category by key; none until the person decides |
Events
| Name | Payload | Description |
|---|---|---|
update:modelValue | [value: Record<string, boolean> | undefined] | |
change | [consent: Record<string, boolean>] |