Skip to content

Granular Toggles Panel

A copy-paste cookie & consent component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.

Cookie & ConsentHTMLCSSany framework
Cookie Preferences
EssentialRequired for the site to work
AnalyticsHelp us improve performance
MarketingPersonalised advertisements

Copy into your project

HTML
<div class="nuda-ck-toggles">
  <div class="nuda-ck-toggles__head">
    <span class="nuda-ck-toggles__title">Cookie Preferences</span>
    <button class="nuda-ck-toggles__close" aria-label="Close">&times;</button>
  </div>
  <div class="nuda-ck-toggles__list">
    <!-- Essential (locked on) -->
    <div class="nuda-ck-toggles__row">
      <div class="nuda-ck-toggles__info">
        <span class="nuda-ck-toggles__label">Essential</span>
        <span class="nuda-ck-toggles__desc">Required for the site to work</span>
      </div>
      <div class="nuda-ck-toggles__switch nuda-ck-toggles__switch--on nuda-ck-toggles__switch--locked">
        <span class="nuda-ck-toggles__thumb"></span>
      </div>
    </div>
    <!-- Analytics (on) -->
    <div class="nuda-ck-toggles__row">
      <div class="nuda-ck-toggles__info">
        <span class="nuda-ck-toggles__label">Analytics</span>
        <span class="nuda-ck-toggles__desc">Help us improve performance</span>
      </div>
      <div class="nuda-ck-toggles__switch nuda-ck-toggles__switch--on">
        <span class="nuda-ck-toggles__thumb"></span>
      </div>
    </div>
    <!-- Marketing (off) -->
    <div class="nuda-ck-toggles__row">
      <div class="nuda-ck-toggles__info">
        <span class="nuda-ck-toggles__label">Marketing</span>
        <span class="nuda-ck-toggles__desc">Personalised advertisements</span>
      </div>
      <div class="nuda-ck-toggles__switch">
        <span class="nuda-ck-toggles__thumb"></span>
      </div>
    </div>
  </div>
  <div class="nuda-ck-toggles__footer">
    <button class="nuda-ck-toggles__save">Save preferences</button>
  </div>
</div>
CSS
.nuda-ck-toggles {
  background: #141414;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  width: 240px;
  overflow: hidden;
  animation: _nuda-cktogIn .45s cubic-bezier(.16,1,.3,1) both;
  box-shadow: 0 20px 50px rgba(0,0,0,.6);
}

.nuda-ck-toggles__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.nuda-ck-toggles__title {
  color: #fafafa;
  font-size: .8rem;
  font-weight: 700;
}

.nuda-ck-toggles__close {
  background: none;
  border: none;
  color: #555;
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.nuda-ck-toggles__close:hover {
  color: #cfcfcf;
}

.nuda-ck-toggles__list {
  padding: .4rem 0;
}

.nuda-ck-toggles__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .55rem 1rem;
}

.nuda-ck-toggles__info {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  flex: 1;
  min-width: 0;
}

.nuda-ck-toggles__label {
  color: #cfcfcf;
  font-size: .75rem;
  font-weight: 600;
}

.nuda-ck-toggles__desc {
  color: #555;
  font-size: .65rem;
  line-height: 1.3;
}

.nuda-ck-toggles__switch {
  position: relative;
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s;
}

.nuda-ck-toggles__switch--on {
  background: #e4ff54;
}

.nuda-ck-toggles__switch--locked {
  opacity: .5;
  cursor: not-allowed;
}

.nuda-ck-toggles__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #0a0a0a;
  transition: transform .2s;
}

.nuda-ck-toggles__switch--on .nuda-ck-toggles__thumb {
  transform: translateX(14px);
}

.nuda-ck-toggles__switch--locked .nuda-ck-toggles__thumb {
  background: #555;
}

.nuda-ck-toggles__footer {
  padding: .65rem 1rem;
  border-top: 1px solid rgba(255,255,255,.07);
}

.nuda-ck-toggles__save {
  width: 100%;
  background: #e4ff54;
  color: #0a0a0a;
  border: none;
  border-radius: 8px;
  padding: .45rem 0;
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}

.nuda-ck-toggles__save:hover {
  opacity: .85;
}

@keyframes _nuda-cktogIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion:reduce) {
  .nuda-ck-toggles {
    animation: none;
  }
}

How to use Granular Toggles Panel

Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.

Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.

More cookie & consent components

← Browse all NudaUI components