JSFiddle - React, Tailwind, and code Playground
HTML
<script
src="https://cc.cdn.civiccomputing.com/9/cookieControl-9.6.1.min.js"
type="text/javascript"
></script>
<h2>Cookies on [name of service]</h2>
<h3>Analytics cookies</h3>
<p>
Analytics cookies help us to improve our website by collecting and reporting information on its usage.
</p>
<div class="analytics-button-group">
<button
type="button"
class="analytics-button"
data-module="analytics-button"
onclick="CookieControl.changeCategory(0, true)"
>
Accept analytics cookies
</button>
<button
type="button"
class="analytics-button"
data-module="analytics-button"
onclick="CookieControl.changeCategory(0, false)"
>
Reject analytics cookies
</button>
</div>
CSS
h2 {
font-size: 2.25rem;
line-height: 1;
color: #0b0c0c;
font-family: arial, sans-serif;
font-weight: 700;
}
h3 {
font-size: 1.25rem;
line-height: 1;
color: #0b0c0c;
font-family: arial, sans-serif;
}
p{
color: #0b0c0c;
font-family: arial, sans-serif;
}
div {
display: block;
}
.analytics-button-group {
display: flex;
flex-wrap: wrap;
position: relative;
margin-bottom: 10px;
}
.analytics-button {
font-family: arial, sans-serif;
box-sizing: border-box;
display: inline-block;
position: relative;
margin-top: 0;
margin-right: 0;
margin-left: 5px;
margin-bottom: 22px;
padding: 8px 10px 7px;
gap: 4px;
border: 2px solid rgba(0, 0, 0, 0);
border-radius: 0;
color: #fff;
background-color: #0e1a2e;
box-shadow: 0 2px 0 #0a1220;
text-align: center;
vertical-align: top;
cursor: pointer;
}
.analytics-button:hover {
background-color: #1e2e4b;
}
.analytics-button:active {
top: 2px;
}
JavaScript
var config = {
apiKey: '592b99ebdf88c091dad9b556b6d8de236ac97687',
product: 'PRO_MULTISITE',
initialState: 'closed',
optionalCookies: [
// first category in array
{
name : 'analytics',
label: 'Analytics Cookies',
description: 'Analytics cookies help us to improve our website by collecting and reporting information on its usage.',
onAccept : function(){
console.log('analytics accepted')
},
onRevoke: function(){
console.log('analytics revoked')
}
}
],
};
CookieControl.load( config );