MorphCanvas
HomeGallery › Color Palette Generator

Color Palette Generator

Generates harmonious five-color palettes; click any swatch to copy its hex code.

★ 0 community votes · Safety scan passed · Sandboxed preview

About this component

Color Palette Generator is an interface component generated on MorphCanvas, an infinite AI workspace that turns written intent into reviewable HTML, CSS, and JavaScript widgets. This component passed MorphCanvas’s automated safety scan, which checks for unsafe patterns such as external network calls, storage access, inline event handlers, and code execution, and it is rendered here inside a sandboxed preview frame.

How it was built

A creator described the result they wanted, MorphCanvas routed the request through its AI provider chain with automatic failover, scanned the generated code, and published the reviewed component to the public library. You can build and publish your own components on the MorphCanvas canvas.

Source

HTML

<div class="cp-box"><div class="cp-row" id="cpRow"></div><button id="cpBtn">Generate palette</button><p id="cpMsg">Click a swatch to copy its hex code.</p></div>

CSS

.cp-box{max-width:420px;margin:24px auto;padding:22px;border-radius:14px;background:#101722;border:1px solid #24344b;font-family:system-ui,sans-serif;text-align:center}.cp-row{display:flex;gap:8px;height:110px;margin-bottom:14px}.cp-swatch{flex:1;border-radius:10px;cursor:pointer;display:flex;align-items:flex-end;justify-content:center;padding-bottom:8px;color:#fff;font-size:11px;font-weight:700;text-shadow:0 1px 3px rgba(0,0,0,.5);transition:transform .15s}.cp-swatch:hover{transform:scale(1.05)}#cpBtn{padding:10px 22px;border:0;border-radius:8px;background:#7ef0e4;color:#06231f;font-weight:700;cursor:pointer}#cpMsg{color:#8fa3b8;font-size:12px;margin:10px 0 0}

JavaScript

function hsl2hex(h,s,l){l/=100;var a=s*Math.min(l,1-l)/100;function f(n){var k=(n+h/30)%12;var c=l-a*Math.max(Math.min(k-3,9-k,1),-1);return Math.round(255*c).toString(16).padStart(2,"0");}return "#"+f(0)+f(8)+f(4);}function paint(){var row=document.getElementById("cpRow");while(row.firstChild){row.removeChild(row.firstChild);}var base=Math.floor(Math.random()*360);for(var i=0;i<5;i++){var hex=hsl2hex((base+i*28)%360,62,38+i*9);var d=document.createElement("div");d.className="cp-swatch";d.style.background=hex;d.textContent=hex;d.onclick=(function(h){return function(){if(navigator.clipboard)navigator.clipboard.writeText(h);document.getElementById("cpMsg").textContent="Copied "+h+" to clipboard";};})(hex);row.appendChild(d);}}document.getElementById("cpBtn").onclick=paint;paint();
Build your own on MorphCanvas