Hex Input
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
<label class="nuda-hexin">
<span class="nuda-hexin__chip" style="background:#e4ff54"></span>
<span class="nuda-hexin__hash">#</span>
<input value="E4FF54" maxlength="6" />
</label>JavaScript
const wrap = document.querySelector('.nuda-hexin');
const chip = wrap.querySelector('.nuda-hexin__chip');
const input = wrap.querySelector('input');
input.addEventListener('input', () => {
const v = input.value.replace(/[^0-9a-f]/gi, '').slice(0, 6);
input.value = v.toUpperCase();
if (v.length === 6) chip.style.background = '#' + v;
});CSS
.nuda-hexin {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 6px 12px 6px 6px;
background: rgba(0,0,0,.3);
border: 1px solid rgba(255,255,255,.08);
border-radius: 10px;
transition: border-color .25s,box-shadow .25s;
}
.nuda-hexin:focus-within {
border-color: #e4ff54;
box-shadow: 0 0 0 3px rgba(228,255,84,.12);
}
.nuda-hexin__chip {
width: 22px;
height: 22px;
border-radius: 6px;
box-shadow: inset 0 0 0 1px rgba(255,255,255,.1);
transition: background .35s;
}
.nuda-hexin__hash {
color: #63636e;
font-family: ui-monospace,SFMono-Regular,Menlo,monospace;
font-size: 13px;
}
.nuda-hexin input {
background: transparent;
border: 0;
outline: none;
color: #fafafa;
font-family: ui-monospace,SFMono-Regular,Menlo,monospace;
font-size: 13px;
font-weight: 600;
letter-spacing: .08em;
text-transform: uppercase;
width: 84px;
}
How to use Hex Input
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.