Colour Harmony Wheel
Pick a base hue and a harmony rule; the wheel shows the chosen hues and the swatches show their hex codes.
AI prompt
Poster in a triadic colour harmony built from a coral base (#F2552C), a green and a blue-violet taken from the wheel: three flat colour blocks of different sizes at about 60, 30 and 10 percent, clean geometric shapes, soft grain, off-white background, balanced composition, modern print feel. Use the hex codes shown on the wheel: base hue, then the other hues the rule picks. Harmony variants: analogous (three neighbouring hues, calm), complementary (two opposite hues, bold contrast), split-complementary (one hue plus the two beside its opposite), tetradic (two complementary pairs, rich). Negative: muddy mixed colours, rainbow gradients, neon on neon, low-contrast text, extra colours.About this pattern
Definition
Colour harmonies are rules for choosing hues from the colour wheel. Analogous uses neighbours, complementary uses opposites, triadic three evenly spaced hues, split-complementary one hue plus the two beside its opposite, and tetradic two opposite pairs.
When to use it
- Harmonies give a starting palette that looks intentional; adjust lightness and saturation afterwards.
- Analogous is calm, complementary is punchy, triadic is playful, split-complementary is balanced.
- Give hex codes or colour names in prompts so the result matches the palette.
What the controls do
- Five rule buttons and a Hue slider; clicking a swatch copies its hex code.
Motion & timing
- The wheel redraws instantly as controls change.
- Reduced motion: no difference.
Tips & variations
- Swatches wrap on small screens; tap one to copy its hex code.
- Always check text contrast against the chosen colours.
Code of this live preview
<div class="bx"><canvas id="cv" width="300" height="130" role="img" aria-label="Colour wheel with chosen hues"></canvas>
<div class="pre" id="pre" role="group" aria-label="Harmony"><button data-h="an">Analog.</button><button data-h="co" aria-pressed="true">Compl.</button><button data-h="tr">Triad</button><button data-h="sp">Split</button><button data-h="te">Tetrad</button></div>
<label class="ctl">Hue <b id="hv">12°</b><input id="h" type="range" min="0" max="359" value="12"></label><div class="sw" id="sw"></div><p class="out" id="out" aria-live="polite"></p></div>:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
.bx{width:min(300px,100%);display:grid;gap:8px}
canvas{display:block;width:100%;height:auto;border-radius:12px;background:#fff;border:1px solid var(--line)}
.pre{display:grid;grid-template-columns:repeat(5,1fr);gap:4px}
.pre button{height:28px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font:inherit;font-size:10.5px;cursor:pointer;padding:0}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.ctl{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.ctl b{color:var(--text)}
input[type=range]{width:100%;accent-color:#171717}
.sw{display:flex;gap:4px}.sw button{flex:1;height:34px;border:1px solid var(--line);border-radius:8px;font:inherit;font-size:10.5px;font-weight:600;cursor:pointer}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.out{font-size:12px;color:var(--muted);min-height:16px}
@media (prefers-reduced-motion:reduce){*{transition:none}}const cv=document.getElementById('cv'),cx=cv.getContext('2d'),h=document.getElementById('h'),hv=document.getElementById('hv'),sw=document.getElementById('sw'),out=document.getElementById('out'),bs=[...document.querySelectorAll('#pre button')];let rule='co';
const R={an:[0,30,-30],co:[0,180],tr:[0,120,240],sp:[0,150,210],te:[0,90,180,270]};
function hex(H,S,L){S/=100;L/=100;const k=n=>(n+H/30)%12,a=S*Math.min(L,1-L),f=n=>Math.round(255*(L-a*Math.max(-1,Math.min(k(n)-3,Math.min(9-k(n),1)))));return '#'+[f(0),f(8),f(4)].map(v=>v.toString(16).padStart(2,'0')).join('').toUpperCase();}
function draw(){const H=+h.value,cx0=65,cy0=65,Ro=56,Ri=30;cx.clearRect(0,0,300,130);
for(let a=0;a<360;a+=2){cx.beginPath();cx.arc(cx0,cy0,Ro,(a-90)*Math.PI/180,(a-88)*Math.PI/180);cx.arc(cx0,cy0,Ri,(a-88)*Math.PI/180,(a-90)*Math.PI/180,true);cx.closePath();cx.fillStyle='hsl('+a+',75%,55%)';cx.fill();}
const hs=R[rule].map(d=>(H+d+360)%360);cx.strokeStyle='#171717';cx.lineWidth=1.5;cx.beginPath();hs.forEach((a,i)=>{const r=(a-90)*Math.PI/180,x=cx0+Math.cos(r)*Ri,y=cy0+Math.sin(r)*Ri;i?cx.lineTo(x,y):cx.moveTo(x,y);});cx.closePath();cx.stroke();
hs.forEach(a=>{const r=(a-90)*Math.PI/180;cx.beginPath();cx.arc(cx0+Math.cos(r)*(Ro+Ri)/2,cy0+Math.sin(r)*(Ro+Ri)/2,7,0,6.283);cx.fillStyle='hsl('+a+',75%,55%)';cx.fill();cx.lineWidth=2.5;cx.strokeStyle='#fff';cx.stroke();cx.lineWidth=1;cx.strokeStyle='#171717';cx.stroke();});
cx.fillStyle='#171717';cx.font='600 13px system-ui,sans-serif';cx.fillText(({an:'Analogous',co:'Complementary',tr:'Triadic',sp:'Split-complementary',te:'Tetradic'})[rule],150,60);cx.font='12px system-ui,sans-serif';cx.fillStyle='#6f6f6f';cx.fillText(hs.map(a=>Math.round(a)+'°').join(' '),150,80);
hv.textContent=H+'°';sw.innerHTML='';hs.forEach(a=>{const c=hex(a,75,55),b=document.createElement('button');b.type='button';b.style.background=c;b.style.color='#fff';b.style.textShadow='0 0 3px rgba(0,0,0,.6)';b.textContent=c;b.setAttribute('aria-label','Copy '+c);
b.addEventListener('click',()=>{try{navigator.clipboard.writeText(c).then(()=>out.textContent='Copied '+c,()=>out.textContent=c);}catch(e){out.textContent=c;}});sw.append(b);});}
bs.forEach(b=>b.addEventListener('click',()=>{rule=b.dataset.h;bs.forEach(x=>x.setAttribute('aria-pressed',String(x===b)));draw();}));h.addEventListener('input',draw);draw();One complete HTML file. Save it and open it in a browser.
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Colour Harmony Wheel — demo</title>
<style>
:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
html,body{height:100%}body{background:var(--bg);color:var(--text);font:15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Inter,Roboto,sans-serif;-webkit-font-smoothing:antialiased}.stage{min-height:100%;display:grid;place-items:center;padding:24px}button,input,select,textarea{font-family:inherit}@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}}
.bx{width:min(300px,100%);display:grid;gap:8px}
canvas{display:block;width:100%;height:auto;border-radius:12px;background:#fff;border:1px solid var(--line)}
.pre{display:grid;grid-template-columns:repeat(5,1fr);gap:4px}
.pre button{height:28px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font:inherit;font-size:10.5px;cursor:pointer;padding:0}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.ctl{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.ctl b{color:var(--text)}
input[type=range]{width:100%;accent-color:#171717}
.sw{display:flex;gap:4px}.sw button{flex:1;height:34px;border:1px solid var(--line);border-radius:8px;font:inherit;font-size:10.5px;font-weight:600;cursor:pointer}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.out{font-size:12px;color:var(--muted);min-height:16px}
@media (prefers-reduced-motion:reduce){*{transition:none}}
</style></head>
<body><div class="stage">
<div class="bx"><canvas id="cv" width="300" height="130" role="img" aria-label="Colour wheel with chosen hues"></canvas>
<div class="pre" id="pre" role="group" aria-label="Harmony"><button data-h="an">Analog.</button><button data-h="co" aria-pressed="true">Compl.</button><button data-h="tr">Triad</button><button data-h="sp">Split</button><button data-h="te">Tetrad</button></div>
<label class="ctl">Hue <b id="hv">12°</b><input id="h" type="range" min="0" max="359" value="12"></label><div class="sw" id="sw"></div><p class="out" id="out" aria-live="polite"></p></div>
</div>
<script>
const cv=document.getElementById('cv'),cx=cv.getContext('2d'),h=document.getElementById('h'),hv=document.getElementById('hv'),sw=document.getElementById('sw'),out=document.getElementById('out'),bs=[...document.querySelectorAll('#pre button')];let rule='co';
const R={an:[0,30,-30],co:[0,180],tr:[0,120,240],sp:[0,150,210],te:[0,90,180,270]};
function hex(H,S,L){S/=100;L/=100;const k=n=>(n+H/30)%12,a=S*Math.min(L,1-L),f=n=>Math.round(255*(L-a*Math.max(-1,Math.min(k(n)-3,Math.min(9-k(n),1)))));return '#'+[f(0),f(8),f(4)].map(v=>v.toString(16).padStart(2,'0')).join('').toUpperCase();}
function draw(){const H=+h.value,cx0=65,cy0=65,Ro=56,Ri=30;cx.clearRect(0,0,300,130);
for(let a=0;a<360;a+=2){cx.beginPath();cx.arc(cx0,cy0,Ro,(a-90)*Math.PI/180,(a-88)*Math.PI/180);cx.arc(cx0,cy0,Ri,(a-88)*Math.PI/180,(a-90)*Math.PI/180,true);cx.closePath();cx.fillStyle='hsl('+a+',75%,55%)';cx.fill();}
const hs=R[rule].map(d=>(H+d+360)%360);cx.strokeStyle='#171717';cx.lineWidth=1.5;cx.beginPath();hs.forEach((a,i)=>{const r=(a-90)*Math.PI/180,x=cx0+Math.cos(r)*Ri,y=cy0+Math.sin(r)*Ri;i?cx.lineTo(x,y):cx.moveTo(x,y);});cx.closePath();cx.stroke();
hs.forEach(a=>{const r=(a-90)*Math.PI/180;cx.beginPath();cx.arc(cx0+Math.cos(r)*(Ro+Ri)/2,cy0+Math.sin(r)*(Ro+Ri)/2,7,0,6.283);cx.fillStyle='hsl('+a+',75%,55%)';cx.fill();cx.lineWidth=2.5;cx.strokeStyle='#fff';cx.stroke();cx.lineWidth=1;cx.strokeStyle='#171717';cx.stroke();});
cx.fillStyle='#171717';cx.font='600 13px system-ui,sans-serif';cx.fillText(({an:'Analogous',co:'Complementary',tr:'Triadic',sp:'Split-complementary',te:'Tetradic'})[rule],150,60);cx.font='12px system-ui,sans-serif';cx.fillStyle='#6f6f6f';cx.fillText(hs.map(a=>Math.round(a)+'°').join(' '),150,80);
hv.textContent=H+'°';sw.innerHTML='';hs.forEach(a=>{const c=hex(a,75,55),b=document.createElement('button');b.type='button';b.style.background=c;b.style.color='#fff';b.style.textShadow='0 0 3px rgba(0,0,0,.6)';b.textContent=c;b.setAttribute('aria-label','Copy '+c);
b.addEventListener('click',()=>{try{navigator.clipboard.writeText(c).then(()=>out.textContent='Copied '+c,()=>out.textContent=c);}catch(e){out.textContent=c;}});sw.append(b);});}
bs.forEach(b=>b.addEventListener('click',()=>{rule=b.dataset.h;bs.forEach(x=>x.setAttribute('aria-pressed',String(x===b)));draw();}));h.addEventListener('input',draw);draw();
</script>
</body></html>