Pages

Thursday, 19 December 2024

Color Scheme Generator Tool



Color Scheme Generator

Color Scheme Generator

* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: Arial, sans-serif; background: #f4f4f4; display: flex; justify-content: center; align-items: center; height: 100vh; padding: 10px; } .container { text-align: center; background: #fff; border-radius: 10px; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); padding: 30px; max-width: 400px; width: 100%; } h1 { margin-bottom: 20px; color: #333; } .color-scheme { display: flex; justify-content: space-between; margin-bottom: 20px; } .color { width: 18%; height: 80px; border-radius: 5px; cursor: pointer; transition: all 0.3s ease; } button { background-color: #5C6BC0; color: white; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer; margin: 5px; font-size: 16px; } button:hover { background-color: #3F51B5; } #status { margin-top: 20px; color: #777; font-size: 14px; } @media (max-width: 600px) { .color-scheme { flex-direction: column; gap: 10px; } .color { width: 100%; } } document.getElementById('generateBtn').addEventListener('click', generateColors); document.getElementById('copyBtn').addEventListener('click', copyColors); function generateColors() { const colors = chroma.random().scale(['#f4f4f4', '#000000']).mode('lab').colors(5); for (let i = 0; i < colors.length; i++) { document.getElementById(`color${i + 1}`).style.backgroundColor = colors[i]; } document.getElementById('status').textContent = "New color scheme generated!"; } function copyColors() { let colorValues = ''; for (let i = 1; i <= 5; i++) { colorValues += document.getElementById(`color${i}`).style.backgroundColor + '\n'; } navigator.clipboard.writeText(colorValues).then(() => { document.getElementById('status').textContent = "Colors copied to clipboard!"; }, () => { document.getElementById('status').textContent = "Failed to copy colors."; }); }