Nuxt Cookie Control
Try it out here:
Nuxt.js Cookie Control
🚀 Usage
npm i nuxt-cookie-control
modules: [
'nuxt-cookie-control'
]
modules: [
['nuxt-cookie-control', {
}]
]
$cookies.modal = true
this.$cookies.modal = true
<CookieControl/>
<CookieControl></CookieControl>
Slot
Bar
<CookieControl>
<template v-slot:bar>
<h3>Bar title</h3>
<p>Bar description (you can use $cookies.text.barDescription)</p>
<n-link>Go somewhere</n-link>
</template>
</CookieControl>
Modal
<template v-slot:modal>
<h3>Modal title</h3>
<p>Modal description</p>
</template>
Cookie
<template v-slot:cookie="{config}">
<span v-for="c in config" :key="c.id" v-text="c.cookies"/>
</template>
Props
Locale
<CookieControl locale="de"/>
Default: en,
Currently available:
🔧 Options
Options in nuxt.config.js
modules: [
['nuxt-cookie-control', {
css: true,
cssPolyfill: true,
domain: 'yourdomain.com',
locales: ['en', 'de'],
controlButton: true,
blockIframe: true,
blockIframe: {
initialState: false
},
barPosition: 'bottom-full',
dashInDescription: true,
colors: {
barTextColor: '#fff',
modalOverlay: '#000',
barBackground: '#000',
barButtonColor: '#000',
modalTextColor: '#000',
modalBackground: '#fff',
modalOverlayOpacity: 0.8,
modalButtonColor: '#fff',
modalUnsavedColor: '#fff',
barButtonHoverColor: '#fff',
barButtonBackground: '#fff',
modalButtonHoverColor: '#fff',
modalButtonBackground: '#000',
controlButtonIconColor: '#000',
controlButtonBackground: '#fff',
barButtonHoverBackground: '#333',
checkboxActiveBackground: '#000',
checkboxInactiveBackground: '#000',
modalButtonHoverBackground: '#333',
checkboxDisabledBackground: '#ddd',
controlButtonIconHoverColor: '#fff',
controlButtonHoverBackground: '#000',
checkboxActiveCircleBackground: '#fff',
checkboxInactiveCircleBackground: '#fff',
checkboxDisabledCircleBackground: '#fff',
},
text: {
barTitle: 'Cookies',
barDescription: 'We use our own cookies and third-party cookies so that we can show you this website and better understand how you use it, with a view to improving the services we offer. If you continue browsing, we consider that you have accepted the cookies.',
acceptAll: 'Accept all',
declineAll: 'Delete all',
manageCookies: 'Manage cookies',
unsaved: 'You have unsaved settings',
close: 'Close',
save: 'Save',
necessary: 'Necessary cookies',
optional: 'Optional cookies',
functional: 'Functional cookies',
blockedIframe: 'To see this, please enable functional cookies',
here: 'here'
}
]
]
without options (Simple)
modules: [
'nuxt-cookie-control'
]
Cookies
modules: [
'nuxt-cookie-control'
]
...
...
...
cookies: {
necessary: [
{
name: {
en: 'Default Cookies'
},
name: 'Default Cookies',
description: {
en: 'Used for cookie control.'
},
description: 'Used for cookie control.',
cookies: ['cookie_control_consent', 'cookie_control_enabled_cookies']
}
],
optional: [
{
name: 'Google Analitycs',
identifier: 'ga',
description: {
en: 'Google GTM is ...'
},
description: 'Google GTM is...',
initialState: true,
src: 'https://www.googletagmanager.com/gtag/js?id=<API-KEY>',
async: true,
cookies: ['_ga', '_gat', '_gid'],
accepted: () =>{
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'gtm.start': new Date().getTime(),
event: 'gtm.js'
});
},
declined: () =>{
}
}
]
}
Multilanguage
Set locale prop
<CookieControl locale="de"/>
Default: en,
Currently available:
If you don't like the default texts you can change them in options (nuxt.config.js)
text: {
locale: {
en: {
barTitle: 'Cookies Different',
barDescription: 'We use our own cookies and third-party...',
},
de: {
...
}
},
barTitle: 'Override Title'
}
Buy me a coffee