Skip to content

Eye Dropper

A copy-paste color pickers component in pure HTML, CSS & vanilla JS. Zero dependencies, framework-agnostic, MIT-licensed.

Color PickersHTMLJavaScriptCSSany framework

Copy into your project

HTML
<button class="nuda-eyedrop" aria-label="Pick color from screen">
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"
       stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
    <path d="M2 22l1-1 8.5-8.5" />
    <path d="M11.5 12.5l4-4" />
    <path d="M14 6l4 4" />
    <path d="M17.5 3.5a2.12 2.12 0 113 3L20 7.5l-3-3z" />
  </svg>
  <span class="nuda-eyedrop__drop"></span>
</button>
JavaScript
// Modern browsers expose the EyeDropper API on secure origins
const btn = document.querySelector('.nuda-eyedrop');

btn.addEventListener('click', async () => {
  if (!window.EyeDropper) return alert('EyeDropper API not supported here.');
  try {
    const dropper = new EyeDropper();
    const { sRGBHex } = await dropper.open();
    console.log('Picked', sRGBHex);
  } catch {
    // User cancelled
  }
});
CSS
.nuda-eyedrop {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  color: #fafafa;
  cursor: pointer;
  overflow: visible;
  transition: background .25s,transform .2s,border-color .25s;
}

.nuda-eyedrop:hover {
  background: rgba(228,255,84,.08);
  border-color: #e4ff54;
  color: #e4ff54;
  transform: translateY(-2px) rotate(-6deg);
}

.nuda-eyedrop svg {
  width: 18px;
  height: 18px;
}

.nuda-eyedrop__drop {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 0 100% 100% 100%;
  background: #e4ff54;
  opacity: 0;
  animation: _eyedDrop 1.8s ease-in-out infinite;
}

@keyframes _eyedDrop {
  0% {
    opacity: 1;
    transform: translate(-50%,-12px) rotate(-45deg) scale(.4);
  }
  60% {
    transform: translate(-50%,8px) rotate(-45deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%,16px) rotate(-45deg) scale(.6);
  }
}

@media (prefers-reduced-motion:reduce) {
  .nuda-eyedrop__drop {
    animation: none;
    opacity: 0;
  }
}

How to use Eye Dropper

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 color pickers components

← Browse all NudaUI components