Format Switcher
A copy-paste color pickers component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.
Color PickersHTMLCSSany framework
#9D6DFF
Copy into your project
HTML
<div class="nuda-cpk2-format-switcher">
<div class="nuda-cpk2-format-switcher__tabs" role="radiogroup" aria-label="Color format">
<button type="button" class="nuda-cpk2-format-switcher__tab is-active"
role="radio" aria-checked="true">HEX</button>
<button type="button" class="nuda-cpk2-format-switcher__tab"
role="radio" aria-checked="false">RGB</button>
<button type="button" class="nuda-cpk2-format-switcher__tab"
role="radio" aria-checked="false">HSL</button>
</div>
<div class="nuda-cpk2-format-switcher__readout">
<span class="nuda-cpk2-format-switcher__swatch" style="background:#9d6dff"></span>
<span class="nuda-cpk2-format-switcher__value" aria-live="polite">#9D6DFF</span>
</div>
</div>CSS
.nuda-cpk2-format-switcher {
display: flex;
flex-direction: column;
gap: 8px;
padding: 10px;
background: rgba(255,255,255,.02);
border: 1px solid rgba(255,255,255,.06);
border-radius: 10px;
width: 100%;
max-width: 220px;
}
.nuda-cpk2-format-switcher__tabs {
display: flex;
gap: 4px;
padding: 3px;
background: rgba(255,255,255,.04);
border-radius: 8px;
}
.nuda-cpk2-format-switcher__tab {
flex: 1;
min-height: 44px;
border: 0;
border-radius: 6px;
background: transparent;
color: #a0a0a8;
font-size: 10px;
font-weight: 700;
letter-spacing: .04em;
cursor: pointer;
transition: background .2s,color .2s,transform .15s;
}
.nuda-cpk2-format-switcher__tab:hover {
color: #fafafa;
}
.nuda-cpk2-format-switcher__tab.is-active {
background: #e4ff54;
color: #0a0a0a;
}
.nuda-cpk2-format-switcher__tab:focus-visible {
outline: 2px solid #e4ff54;
outline-offset: 2px;
}
.nuda-cpk2-format-switcher__readout {
display: flex;
align-items: center;
gap: 8px;
padding: 8px;
background: rgba(255,255,255,.03);
border: 1px solid rgba(255,255,255,.06);
border-radius: 8px;
}
.nuda-cpk2-format-switcher__swatch {
width: 22px;
height: 22px;
border-radius: 6px;
box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.nuda-cpk2-format-switcher__value {
font-family: ui-monospace,SFMono-Regular,Menlo,monospace;
font-size: 12px;
font-weight: 600;
color: #fafafa;
letter-spacing: .02em;
}
@media (prefers-reduced-motion:reduce) {
.nuda-cpk2-format-switcher__tab {
transition: none;
}
}
How to use Format Switcher
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.