Liveweave: Generative AI Web Editor & HTML/CSS/JS Playground
Initializing
Liveweave
Web
expand_more
home
Home
Palette
Color Explorer
arrow_outward
Polyline
Graphics Editor
arrow_outward
frame_source
Python Playground
arrow_outward
build
Tools
expand_more
restart_alt
Load "Hello Weaver!"
post_add
Generate Lorem ipsum...
code
Format HTML
code_blocks
Format CSS
data_object
Format JavaScript
library_add
Library
expand_more
A
Algolia JS
Animate CSS
Apex Charts JS
B
Bulma CSS
Bootstrap
C
Chart JS
Chartist
Create JS
D
D3
Dojo
F
Foundation
Fullpage JS
G
Granim JS
Google Charts
H
Halfmoon
J
jQuery
M
Materialize
Moment JS
Masonry JS
Milligram CSS
P
Pure CSS
Primer CSS
Popper JS
Pattern CSS
Picnic CSS
R
React JS
Raphael JS
Raisin CSS
S
Semantic UI
Skeleton CSS
Spectre CSS
Tachyons CSS
T
Tailwind
Three JS
U
UI Kit
Vis JS
W
Water CSS
download
Download
expand_more
developer_mode
Download as HTML
folder_zip
Download as .ZIP
cloud_upload
Fork
account_circle
Login
settings
Settings
expand_more
Editor font
14
px
A
A
Night mode
Line number
Mini map
Word wrap
sync_alt
Reset Settings
smart_display
Run
left_panel_close
AI Assistant
dashboard
All
HTML
CSS
JS
visibility
Preview
bolt
Live Preview
terminal
JS Console
<!DOCTYPE html> <html> <head> <title>Color Palette Generator</title> </head> <body> <!-- Start your code here --> <div class="app"> <header class="topbar"> <div class="brand"><span class="brand-icon">◈</span> chroma<span class="brand-light">.</span></div> <div class="top-actions"> <span class="keyboard-hint">SPACE TO GENERATE</span> <button id="exportBtn" class="export-btn">Export CSS ↗</button> </div> </header> <main> <section class="intro"> <div class="eyebrow">YOUR CREATIVE COLOR TOOLKIT</div> <h1>Find your <span>perfect palette.</span></h1> <p>Explore colors, discover combinations, and create something beautiful.</p> </section> <section class="palette-area"> <div class="palette-toolbar"> <div> <span class="section-label">YOUR PALETTE</span> <span class="palette-count" id="paletteCount">01 / 05</span> </div> <div class="format-select"> <label for="format">FORMAT</label> <select id="format"> <option value="hex">HEX</option> <option value="rgb">RGB</option> <option value="hsl">HSL</option> </select> </div> </div> <div class="palette" id="palette"> <div class="color-card"><div class="color-block"></div></div> </div> <div class="generate-row"> <div class="hint"><span>↵</span> Press spacebar to generate</div> <button id="generateBtn" class="generate-btn"> <span>✳</span> Generate palette </button> </div> </section> <section class="bottom-section"> <div class="bottom-heading"> <div> <div class="section-label">COLOR HARMONY</div> <h2>Choose your mood</h2> </div> <span class="subtle-label">ONE CLICK TO EXPLORE</span> </div> <div class="moods"> <button class="mood active" data-mood="random">✳ Random</button> <button class="mood" data-mood="pastel">☁ Pastel</button> <button class="mood" data-mood="vibrant">◉ Vibrant</button> <button class="mood" data-mood="earthy">◌ Earthy</button> <button class="mood" data-mood="monochrome">◐ Mono</button> <button class="mood" data-mood="ocean">≈ Ocean</button> </div> </section> <div class="toast" id="toast">Copied to clipboard!</div> </main> <footer> <span>CHROMA STUDIO</span> <span>MAKE SOMETHING COLORFUL.</span> </footer> </div> <div class="modal-overlay" id="modal"> <div class="modal"> <div class="modal-header"> <h2>Your CSS palette</h2> <button id="closeModal">✕</button> </div> <p>Copy these variables into your stylesheet.</p> <pre id="cssOutput"></pre> <button id="copyCSS" class="generate-btn modal-copy">Copy CSS variables</button> </div> </div> <!-- End your code here --> </body> </html>
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap'); * { box-sizing: border-box; } body { margin: 0; background: #fafafa; color: #20232d; font-family: 'DM Sans', sans-serif; } button, select { font: inherit; } button { cursor: pointer; } .app { max-width: 1200px; margin: auto; padding: 0 35px; } .topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #ececf0; } .brand { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 23px; font-weight: 800; letter-spacing: -1px; } .brand-icon { color: #7863e9; margin-right: 5px; } .brand-light { color: #7863e9; } .top-actions { display: flex; align-items: center; gap: 20px; } .keyboard-hint { color: #a2a3ae; font-size: 9px; letter-spacing: 1.1px; font-weight: 700; } .export-btn { background: #fff; border: 1px solid #e4e4eb; padding: 10px 15px; border-radius: 7px; color: #353746; font-size: 11px; font-weight: 700; } .export-btn:hover { border-color: #7863e9; color: #7863e9; } .intro { text-align: center; padding: 65px 0 48px; } .eyebrow { font-size: 10px; font-weight: 800; letter-spacing: 2px; color: #8875e9; margin-bottom: 15px; } .intro h1 { font-family: 'Plus Jakarta Sans', sans-serif; font-size: clamp(32px, 5vw, 47px); letter-spacing: -2.5px; line-height: 1.2; margin: 0; } .intro h1 span { color: #7964e7; } .intro p { color: #92939e; font-size: 14px; margin-top: 15px; } .palette-area { background: #fff; border: 1px solid #ececf1; padding: 23px; border-radius: 13px; box-shadow: 0 8px 30px rgba(30,30,60,.035); } .palette-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; } .section-label { font-size: 10px; letter-spacing: 1.3px; font-weight: 800; color: #505363; } .palette-count { font-size: 10px; color: #a4a5ae; margin-left: 10px; } .format-select { display: flex; align-items: center; gap: 9px; } .format-select label { font-size: 9px; color: #aaaab4; font-weight: 800; } .format-select select { border: 1px solid #e8e8ee; border-radius: 5px; background: white; padding: 6px 9px; font-size: 10px; color: #454656; outline: none; } .palette { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; } .color-card { min-width: 0; } .color-block { position: relative; height: 255px; border-radius: 9px; overflow: hidden; transition: background .3s; } .color-block:hover .copy-overlay { opacity: 1; } .copy-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.12); color: white; font-size: 11px; font-weight: 700; opacity: 0; transition: opacity .2s; } .color-details { display: flex; justify-content: space-between; align-items: center; gap: 5px; margin-top: 12px; } .hex-code { font-size: 12px; font-weight: 800; letter-spacing: .2px; color: #333543; border: none; background: none; padding: 3px 0; cursor: pointer; } .lock-btn { width: 27px; height: 27px; border: 1px solid #eeeef2; background: #fff; color: #aaaab4; border-radius: 6px; font-size: 13px; transition: .2s; } .lock-btn:hover, .lock-btn.locked { color: #7863e9; background: #f1efff; border-color: #ddd6ff; } .edit-color { display: block; width: 100%; height: 4px; border: 0; padding: 0; background: transparent; cursor: pointer; margin-top: 10px; } .edit-color::-webkit-color-swatch-wrapper { padding: 0; } .edit-color::-webkit-color-swatch { border: 0; border-radius: 3px; } .generate-row { margin-top: 28px; display: flex; justify-content: space-between; align-items: center; } .hint { color: #a3a4af; font-size: 11px; } .hint span { display: inline-block; padding: 4px 8px; border: 1px solid #e8e8ed; border-radius: 5px; color: #555565; margin-right: 5px; } .generate-btn { border: none; background: #7863e9; color: white; padding: 13px 23px; border-radius: 7px; font-size: 12px; font-weight: 700; box-shadow: 0 5px 15px rgba(120,99,233,.2); transition: .2s; } .generate-btn:hover { background: #6550d5; transform: translateY(-2px); box-shadow: 0 8px 20px rgba(120,99,233,.3); } .generate-btn span { font-size: 16px; margin-right: 7px; } .bottom-section { padding: 48px 0 55px; } .bottom-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 20px; } .bottom-heading h2 { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 21px; margin: 8px 0 0; letter-spacing: -.7px; } .subtle-label { font-size: 9px; letter-spacing: 1px; color: #aaaab4; font-weight: 700; } .moods { display: flex; flex-wrap: wrap; gap: 10px; } .mood { background: white; border: 1px solid #e9e9ef; color: #6b6d7a; border-radius: 7px; padding: 11px 17px; font-size: 11px; font-weight: 600; transition: .2s; } .mood:hover { border-color: #b9adff; color: #7863e9; } .mood.active { background: #f1efff; border-color: #cfc5ff; color: #725ce0; } footer { height: 55px; border-top: 1px solid #ececf0; display: flex; justify-content: space-between; align-items: center; color: #b0b0b9; font-size: 9px; letter-spacing: 1.2px; font-weight: 700; } .toast { position: fixed; bottom: 25px; left: 50%; transform: translate(-50%, 20px); background: #222331; color: white; padding: 12px 19px; font-size: 12px; border-radius: 7px; opacity: 0; pointer-events: none; transition: .25s; z-index: 20; } .toast.show { opacity: 1; transform: translate(-50%, 0); } .modal-overlay { position: fixed; inset: 0; background: rgba(25,25,40,.45); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 30; } .modal-overlay.open { display: flex; } .modal { width: 100%; max-width: 470px; background: white; padding: 25px; border-radius: 13px; box-shadow: 0 20px 70px rgba(0,0,0,.2); } .modal-header { display: flex; justify-content: space-between; align-items: center; } .modal-header h2 { font-size: 19px; margin: 0; } .modal-header button { background: none; border: none; color: #888; font-size: 18px; } .modal > p { color: #999; font-size: 12px; } .modal pre { background: #f5f5f8; padding: 17px; border-radius: 8px; font-size: 11px; line-height: 1.8; overflow-x: auto; color: #53516c; } .modal-copy { width: 100%; } @media(max-width: 760px) { .app { padding: 0 18px; } .palette { grid-template-columns: repeat(5, minmax(0,1fr)); gap: 7px; } .color-block { height: 170px; } .hex-code { font-size: 9px; } .lock-btn { width: 23px; height: 23px; } } @media(max-width: 480px) { .keyboard-hint { display: none; } .intro { padding: 48px 0 35px; } .palette-area { padding: 13px; } .color-block { height: 125px; } .color-details { flex-direction: column; align-items: center; } .generate-row { flex-direction: column; gap: 18px; } .generate-btn { width: 100%; } .bottom-heading { align-items: start; } .subtle-label { display: none; } footer { font-size: 8px; } }
const palette = document.getElementById('palette'); const generateBtn = document.getElementById('generateBtn'); const formatSelect = document.getElementById('format'); const toast = document.getElementById('toast'); let colors = ['#7765D8', '#E5A0A1', '#F3C969', '#77B8A6', '#334C67']; let locks = [false, false, false, false, false]; let currentMood = 'random'; let toastTimeout; const presets = { pastel: [ ['#F6CACA','#D7E7F5','#D8E9D5','#F5E2B8','#DCCCF0'], ['#F4C2D7','#C5D9F2','#F5D7A1','#C6E7DF','#D8CDF2'] ], vibrant: [ ['#FF4D6D','#FF9F1C','#FFD60A','#36C9A0','#4361EE'], ['#F72585','#7209B7','#3A0CA3','#4361EE','#4CC9F0'] ], earthy: [ ['#6D5844','#B58B65','#D5B895','#89916F','#434E3C'], ['#705C45','#C08B62','#D7C3A3','#7D8061','#3F493B'] ], ocean: [ ['#06283D','#13678A','#45C4B0','#80EDDB','#D9F8F5'], ['#12355B','#420039','#D8576B','#E7A977','#F4D6A0'] ], monochrome: [ ['#171717','#414141','#777777','#B8B8B8','#EAEAEA'], ['#222831','#393E46','#59636F','#A4ADB7','#E7E9ED'] ] }; function randomHex(mood) { if (mood === 'pastel') { return `hsl(${Math.random()*360}, 55%, 82%)`; } if (mood === 'vibrant') { return `hsl(${Math.random()*360}, 85%, 55%)`; } if (mood === 'earthy') { return `hsl(${Math.random()*65+15}, 30%, ${Math.random()*30+30}%)`; } if (mood === 'ocean') { return `hsl(${Math.random()*65+165}, 65%, ${Math.random()*35+35}%)`; } if (mood === 'monochrome') { const value = Math.floor(Math.random()*210+25); return `rgb(${value},${value},${value})`; } return '#' + Math.floor(Math.random()*16777215) .toString(16).padStart(6,'0'); } function normalizeHex(color) { if (color.startsWith('#')) { let value = color.slice(1); if (/^[0-9a-f]{3}$/i.test(value)) { value = value.split('').map(x => x+x).join(''); } return /^[0-9a-f]{6}$/i.test(value) ? '#' + value.toUpperCase() : '#000000'; } const match = color.match(/[\d.]+/g); if (!match || match.length < 3) return '#000000'; if (color.startsWith('hsl')) { const h = Number(match[0]); const s = Number(match[1]) / 100; const l = Number(match[2]) / 100; const a = s * Math.min(l, 1-l); const f = n => { const k = (n + h/30) % 12; const c = l - a * Math.max(-1, Math.min(k-3, 9-k, 1)); return Math.round(255*c); }; return rgbToHex(f(0),f(8),f(4)); } return rgbToHex(...match.slice(0,3).map(Number)); } function rgbToHex(r,g,b) { return '#' + [r,g,b].map(v => Math.round(v).toString(16).padStart(2,'0') ).join('').toUpperCase(); } function getColorValue(hex, format) { const value = normalizeHex(hex); const r = parseInt(value.slice(1,3),16); const g = parseInt(value.slice(3,5),16); const b = parseInt(value.slice(5,7),16); if (format === 'rgb') return `rgb(${r}, ${g}, ${b})`; if (format === 'hsl') { const rn=r/255, gn=g/255, bn=b/255; const max=Math.max(rn,gn,bn), min=Math.min(rn,gn,bn); const d=max-min; let h=0, s=0; const l=(max+min)/2; if(d) { s=d/(1-Math.abs(2*l-1)); switch(max) { case rn: h=60*(((gn-bn)/d)%6); break; case gn: h=60*((bn-rn)/d+2); break; default: h=60*((rn-gn)/d+4); } } return `hsl(${Math.round((h+360)%360)}, ${Math.round(s*100)}%, ${Math.round(l*100)}%)`; } return value; } function renderPalette() { palette.innerHTML = ''; colors.forEach((color, index) => { const hex = normalizeHex(color); colors[index] = hex; const card = document.createElement('div'); card.className = 'color-card'; const block = document.createElement('div'); block.className = 'color-block'; block.style.background = hex; const overlay = document.createElement('div'); overlay.className = 'copy-overlay'; overlay.textContent = 'COPY COLOR'; block.appendChild(overlay); block.addEventListener('click', () => copyText(getColorValue(hex, formatSelect.value))); const details = document.createElement('div'); details.className = 'color-details'; const code = document.createElement('button'); code.className = 'hex-code'; code.textContent = getColorValue(hex, formatSelect.value); code.addEventListener('click', () => copyText(getColorValue(hex, formatSelect.value))); const lock = document.createElement('button'); lock.className = 'lock-btn' + (locks[index] ? ' locked' : ''); lock.textContent = locks[index] ? '🔒' : '♧'; lock.title = locks[index] ? 'Unlock color' : 'Lock color'; lock.setAttribute('aria-label', lock.title); lock.addEventListener('click', () => { locks[index] = !locks[index]; renderPalette(); }); const picker = document.createElement('input'); picker.type = 'color'; picker.className = 'edit-color'; picker.value = hex; picker.title = 'Edit color'; picker.addEventListener('input', event => { colors[index] = event.target.value.toUpperCase(); renderPalette(); }); details.append(code, lock); card.append(block, details, picker); palette.appendChild(card); }); } function generatePalette() { const presetList = presets[currentMood]; const preset = presetList ? presetList[Math.floor(Math.random()*presetList.length)] : null; colors = colors.map((color,index) => { if (locks[index]) return color; if (preset) return preset[index]; return randomHex(currentMood); }); renderPalette(); } function showToast(message) { toast.textContent = message; toast.classList.add('show'); clearTimeout(toastTimeout); toastTimeout = setTimeout(() => { toast.classList.remove('show'); }, 1700); } async function copyText(text) { try { await navigator.clipboard.writeText(text); showToast('✓ ' + text + ' copied!'); } catch { showToast('Clipboard unavailable'); } } generateBtn.addEventListener('click', generatePalette); document.addEventListener('keydown', event => { if ( event.code === 'Space' && !['INPUT','SELECT','TEXTAREA','BUTTON'].includes(document.activeElement.tagName) ) { event.preventDefault(); generatePalette(); } if (event.key === 'Escape') { document.getElementById('modal').classList.remove('open'); } }); formatSelect.addEventListener('change', renderPalette); document.querySelectorAll('.mood').forEach(button => { button.addEventListener('click', () => { document.querySelector('.mood.active')?.classList.remove('active'); button.classList.add('active'); currentMood = button.dataset.mood; generatePalette(); }); }); // Export CSS function getCSS() { return ':root {\n' + colors.map((color,index) => ` --color-${index+1}: ${normalizeHex(color)};` ).join('\n') + '\n}'; } document.getElementById('exportBtn').addEventListener('click', () => { document.getElementById('cssOutput').textContent = getCSS(); document.getElementById('modal').classList.add('open'); }); document.getElementById('closeModal').addEventListener('click', () => { document.getElementById('modal').classList.remove('open'); }); document.getElementById('modal').addEventListener('click', event => { if (event.target.id === 'modal') { event.currentTarget.classList.remove('open'); } }); document.getElementById('copyCSS').addEventListener('click', () => { copyText(getCSS()); }); renderPalette();
terminal
JavaScript Console
Preview
Clear
close
›
Run