Skip to content

Colour Scheme Picker

A copy-paste css-only interactions component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.

CSS-Only InteractionsHTMLCSSany framework

Copy into your project

HTML
<!-- Colour Scheme Picker — radios drive a --custom-property through
     :has(), recolouring the live preview card. Zero JS. -->
<div class="nuda-co2-scheme-picker">
  <input class="nuda-co2-scheme-picker__input" type="radio" name="nuda-co2-scheme" id="co2-scheme-lime" checked />
  <input class="nuda-co2-scheme-picker__input" type="radio" name="nuda-co2-scheme" id="co2-scheme-sky" />
  <input class="nuda-co2-scheme-picker__input" type="radio" name="nuda-co2-scheme" id="co2-scheme-coral" />

  <div class="nuda-co2-scheme-picker__swatches" role="radiogroup" aria-label="Colour scheme">
    <label class="nuda-co2-scheme-picker__swatch nuda-co2-scheme-picker__swatch--lime" for="co2-scheme-lime">
      <span class="nuda-co2-scheme-picker__sr">Lime</span>
    </label>
    <label class="nuda-co2-scheme-picker__swatch nuda-co2-scheme-picker__swatch--sky" for="co2-scheme-sky">
      <span class="nuda-co2-scheme-picker__sr">Sky</span>
    </label>
    <label class="nuda-co2-scheme-picker__swatch nuda-co2-scheme-picker__swatch--coral" for="co2-scheme-coral">
      <span class="nuda-co2-scheme-picker__sr">Coral</span>
    </label>
  </div>

  <div class="nuda-co2-scheme-picker__preview">
    <span class="nuda-co2-scheme-picker__dot" aria-hidden="true"></span>
    <span class="nuda-co2-scheme-picker__title">Preview card</span>
    <button class="nuda-co2-scheme-picker__cta" type="button">Continue</button>
  </div>
</div>
CSS
.nuda-co2-scheme-picker {
  --nuda-co2-sp-accent: #e4ff54;
  width: 100%;
  max-width: 260px;
  font-family: inherit;
}

.nuda-co2-scheme-picker__input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.nuda-co2-scheme-picker__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.nuda-co2-scheme-picker__swatches {
  display: flex;
  gap: 6px;
  margin: 0 0 .7rem;
}

.nuda-co2-scheme-picker__swatch {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
}

.nuda-co2-scheme-picker__swatch::before {
  content: "";
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--nuda-co2-sp-dot);
  border: 2px solid rgba(255,255,255,.18);
  transition: transform .2s ease,box-shadow .2s ease;
}

.nuda-co2-scheme-picker__swatch--lime {
  --nuda-co2-sp-dot: #e4ff54;
}

.nuda-co2-scheme-picker__swatch--sky {
  --nuda-co2-sp-dot: #7dd3fc;
}

.nuda-co2-scheme-picker__swatch--coral {
  --nuda-co2-sp-dot: #fca5a5;
}

#co2-scheme-lime:checked~.nuda-co2-scheme-picker__swatches label[for=co2-scheme-lime]::before, #co2-scheme-sky:checked~.nuda-co2-scheme-picker__swatches label[for=co2-scheme-sky]::before, #co2-scheme-coral:checked~.nuda-co2-scheme-picker__swatches label[for=co2-scheme-coral]::before {
  box-shadow: 0 0 0 3px #09090b,0 0 0 5px var(--nuda-co2-sp-dot);
  transform: scale(1.08);
}

.nuda-co2-scheme-picker__input:focus-visible~.nuda-co2-scheme-picker__swatches label {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.nuda-co2-scheme-picker__preview {
  --nuda-co2-sp-accent: #e4ff54;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: .65rem .8rem;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  transition: border-color .2s ease;
}

.nuda-co2-scheme-picker:has(#co2-scheme-sky:checked) .nuda-co2-scheme-picker__preview {
  --nuda-co2-sp-accent: #7dd3fc;
}

.nuda-co2-scheme-picker:has(#co2-scheme-coral:checked) .nuda-co2-scheme-picker__preview {
  --nuda-co2-sp-accent: #fca5a5;
}

.nuda-co2-scheme-picker__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--nuda-co2-sp-accent);
  flex-shrink: 0;
  transition: background .2s ease;
}

.nuda-co2-scheme-picker__title {
  flex: 1;
  font-size: .76rem;
  color: #ddd;
}

.nuda-co2-scheme-picker__cta {
  min-height: 34px;
  padding: .3rem .75rem;
  font-size: .7rem;
  font-weight: 700;
  color: #09090b;
  background: var(--nuda-co2-sp-accent);
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: filter .2s ease,background .2s ease;
}

.nuda-co2-scheme-picker__cta:hover {
  filter: brightness(1.1);
}

.nuda-co2-scheme-picker__cta:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

@media (prefers-reduced-motion:reduce) {
  .nuda-co2-scheme-picker__swatch::before,.nuda-co2-scheme-picker__preview,.nuda-co2-scheme-picker__dot,.nuda-co2-scheme-picker__cta {
    transition: none;
  }
}

How to use Colour Scheme Picker

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 css-only interactions components

← Browse all NudaUI components