{"id":8310138,"date":"2025-09-04T05:24:33","date_gmt":"2025-09-04T02:24:33","guid":{"rendered":"https:\/\/elementor.com\/tools\/?p=8310138"},"modified":"2025-09-04T05:37:05","modified_gmt":"2025-09-04T02:37:05","slug":"color-palette-generator","status":"publish","type":"post","link":"https:\/\/elementor.com\/tools\/color-palette-generator\/","title":{"rendered":"Color Palette Generator"},"content":{"rendered":"\t\t<div data-elementor-type=\"container\" data-elementor-id=\"8310136\" class=\"elementor elementor-8310136\" data-elementor-post-type=\"elementor_library\">\n\t\t\t\t<div class=\"elementor-element elementor-element-23691a2c e-flex e-con-boxed e-con e-parent\" data-id=\"23691a2c\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-37c3711c elementor-widget elementor-widget-html\" data-id=\"37c3711c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<style>\r\n    \/* --- Styles Adapted from Your Code --- *\/\r\n    .html-viewer-app {\r\n        width: 100%;\r\n        max-width: 1280px;\r\n        margin: 0 auto;\r\n        padding: 40px 15px;\r\n        background: transparent;\r\n        text-align: center;\r\n    }\r\n\r\n    .format-btn {\r\n        background-color: #000;\r\n        color: white;\r\n        border: none;\r\n        padding: 12px 28px;\r\n        cursor: pointer;\r\n        font-size: 1.125rem;\r\n        font-weight: 500;\r\n        transition: all 0.2s;\r\n        min-width: 15rem;\r\n        text-align: center;\r\n        border-radius: 4px;\r\n        margin-bottom: 40px;\r\n    }\r\n\r\n    .format-btn:is(:hover, :focus, :focus-visible, :active) {\r\n        background-color: #545454;\r\n    }\r\n\r\n    \/* Style for the main generate button, inspired by your #minifyBtn *\/\r\n    #generatePaletteBtn {\r\n        background-color: #ff7be5;\r\n        color: black;\r\n    }\r\n\r\n    #generatePaletteBtn:is(:hover, :focus, :focus-visible, :active) {\r\n        background-color: #ffa8ee;\r\n    }\r\n\r\n    .copy-btn {\r\n        background-color: rgba(255, 255, 255, 0.2);\r\n        color: inherit; \/* Color will be set by parent *\/\r\n        border: 1px solid rgba(255, 255, 255, 0.4);\r\n        padding: 6px 12px;\r\n        border-radius: 4px;\r\n        cursor: pointer;\r\n        font-size: 14px;\r\n        font-family: 'Courier New', monospace;\r\n        transition: background-color 0.2s;\r\n    }\r\n\r\n    .copy-btn:is(:hover, :focus, :focus-visible) {\r\n        background-color: rgba(255, 255, 255, 0.4);\r\n    }\r\n    \r\n    .main-content {\r\n        display: flex;\r\n        flex-wrap: wrap;\r\n        gap: 20px;\r\n        justify-content: center;\r\n    }\r\n\r\n    .success-message {\r\n        position: fixed;\r\n        bottom: 20px; \/* Positioned at the bottom for better visibility *\/\r\n        left: 50%;\r\n        transform: translateX(-50%);\r\n        background-color: #05047E; \/* Using your header color *\/\r\n        color: white;\r\n        padding: 12px 20px;\r\n        border-radius: 4px;\r\n        font-size: 14px;\r\n        opacity: 0;\r\n        transition: all 0.3s ease;\r\n        z-index: 1000;\r\n        pointer-events: none; \/* Prevent interaction when hidden *\/\r\n    }\r\n\r\n    .success-message.show {\r\n        opacity: 1;\r\n        transform: translate(-50%, -10px);\r\n    }\r\n\r\n    \/* --- New Styles for the Palette Generator --- *\/\r\n    .color-swatch {\r\n        flex: 1 1 200px;\r\n        max-width: 220px;\r\n        min-height: 250px;\r\n        display: flex;\r\n        flex-direction: column;\r\n        border-radius: 8px;\r\n        overflow: hidden;\r\n        background: white;\r\n        border: 1.5px solid #EBEBEB;\r\n        box-shadow: 0 4px 15px rgba(0,0,0,0.08);\r\n        transition: transform 0.2s ease-in-out;\r\n    }\r\n    .color-swatch:hover {\r\n        transform: translateY(-5px);\r\n    }\r\n\r\n    .color-display {\r\n        flex-grow: 1;\r\n    }\r\n\r\n    .color-info {\r\n        padding: 15px;\r\n        background-color: #333; \/* Dark background for contrast *\/\r\n        color: white;\r\n        text-align: center;\r\n        font-size: 1.1rem;\r\n    }\r\n\r\n    \/* Responsive adjustments *\/\r\n    @media (max-width: 768px) {\r\n        .html-viewer-app {\r\n            padding: 20px 10px;\r\n        }\r\n        .format-btn {\r\n            width: 100%;\r\n            margin-bottom: 30px;\r\n        }\r\n        .color-swatch {\r\n             flex-basis: 150px;\r\n        }\r\n    }\r\n<\/style>\r\n\r\n<div class=\"html-viewer-app\">\r\n    \r\n    <!-- Using format-btn class with a specific ID for the main action -->\r\n    <button id=\"generatePaletteBtn\" class=\"format-btn\">Generate New Palette<\/button>\r\n\r\n    <!-- This container will be filled with color swatches by the script -->\r\n    <div id=\"paletteContainer\" class=\"main-content\">\r\n        <!-- Color swatches will be generated here -->\r\n    <\/div>\r\n\r\n    <!-- Reusing your success message for copy feedback -->\r\n    <div id=\"copySuccessMessage\" class=\"success-message\"><\/div>\r\n\r\n<\/div>\r\n\r\n<script>\r\n    document.addEventListener('DOMContentLoaded', () => {\r\n        const generateBtn = document.getElementById('generatePaletteBtn');\r\n        const paletteContainer = document.getElementById('paletteContainer');\r\n        const successMessage = document.getElementById('copySuccessMessage');\r\n        let successTimeout;\r\n\r\n        const PALETTE_SIZE = 5;\r\n\r\n        \/\/ --- Core Functions ---\r\n\r\n        \/**\r\n         * Generates a random hexadecimal color code.\r\n         * @returns {string} A color string like \"#RRGGBB\".\r\n         *\/\r\n        const generateRandomColor = () => {\r\n            const hexChars = '0123456789ABCDEF';\r\n            let color = '#';\r\n            for (let i = 0; i < 6; i++) {\r\n                color += hexChars[Math.floor(Math.random() * 16)];\r\n            }\r\n            return color;\r\n        };\r\n\r\n        \/**\r\n         * Clears the container and generates a new set of color swatches.\r\n         *\/\r\n        const generatePalette = () => {\r\n            paletteContainer.innerHTML = ''; \/\/ Clear existing palette\r\n            for (let i = 0; i < PALETTE_SIZE; i++) {\r\n                const color = generateRandomColor();\r\n                const colorSwatch = document.createElement('div');\r\n                colorSwatch.className = 'color-swatch';\r\n\r\n                \/\/ Using data-color attribute to easily retrieve the color for copying\r\n                colorSwatch.innerHTML = `\r\n                    <div class=\"color-display\" style=\"background-color: ${color};\"><\/div>\r\n                    <div class=\"color-info\">\r\n                        <button class=\"copy-btn\" data-color=\"${color}\">${color}<\/button>\r\n                    <\/div>\r\n                `;\r\n                paletteContainer.appendChild(colorSwatch);\r\n            }\r\n        };\r\n\r\n        \/**\r\n         * Shows a temporary success message to the user.\r\n         * @param {string} message - The text to display.\r\n         *\/\r\n        const showSuccessMessage = (message) => {\r\n            clearTimeout(successTimeout); \/\/ Clear any existing timeout\r\n            successMessage.textContent = message;\r\n            successMessage.classList.add('show');\r\n            \r\n            successTimeout = setTimeout(() => {\r\n                successMessage.classList.remove('show');\r\n            }, 2000); \/\/ Message disappears after 2 seconds\r\n        };\r\n        \r\n        \/**\r\n         * Handles clicks within the palette container, specifically for copy buttons.\r\n         * @param {Event} event - The click event.\r\n         *\/\r\n        const handlePaletteClick = (event) => {\r\n            const target = event.target;\r\n            \/\/ Check if a copy button was clicked\r\n            if (target.classList.contains('copy-btn')) {\r\n                const colorToCopy = target.dataset.color;\r\n                \r\n                \/\/ Use the modern Navigator Clipboard API\r\n                navigator.clipboard.writeText(colorToCopy).then(() => {\r\n                    \/\/ On success, show the feedback message\r\n                    showSuccessMessage(`Copied ${colorToCopy} to clipboard!`);\r\n                }).catch(err => {\r\n                    \/\/ On failure, log an error\r\n                    console.error('Failed to copy color: ', err);\r\n                    showSuccessMessage('Could not copy color.');\r\n                });\r\n            }\r\n        };\r\n\r\n\r\n        \/\/ --- Event Listeners ---\r\n\r\n        \/\/ Generate a new palette when the button is clicked\r\n        generateBtn.addEventListener('click', generatePalette);\r\n        \r\n        \/\/ Use event delegation for copy buttons\r\n        paletteContainer.addEventListener('click', handlePaletteClick);\r\n\r\n        \/\/ --- Initial Load ---\r\n        \r\n        \/\/ Generate the first palette when the page loads\r\n        generatePalette();\r\n    });\r\n<\/script>\r\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[22],"tags":[21],"class_list":["post-8310138","post","type-post","status-publish","format-standard","hentry","category-tools","tag-html-css-tools"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Color Palette Generator<\/title>\n<meta name=\"description\" content=\"Effortlessly create stunning website color palettes with Elementor&#039;s free Website Color Palette Generator. Discover harmonious color schemes, refine shades, and get HEX codes for your design.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/elementor.com\/tools\/color-palette-generator\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Color Palette Generator\" \/>\n<meta property=\"og:description\" content=\"Effortlessly create stunning website color palettes with Elementor&#039;s free Website Color Palette Generator. Discover harmonious color schemes, refine shades, and get HEX codes for your design.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/elementor.com\/tools\/color-palette-generator\/\" \/>\n<meta property=\"og:site_name\" content=\"Tools\" \/>\n<meta property=\"article:published_time\" content=\"2025-09-04T02:24:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-04T02:37:05+00:00\" \/>\n<meta name=\"author\" content=\"liz@148.red\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"liz@148.red\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/elementor.com\/tools\/color-palette-generator\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/elementor.com\/tools\/color-palette-generator\/\"},\"author\":{\"name\":\"liz@148.red\",\"@id\":\"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac\"},\"headline\":\"Color Palette Generator\",\"datePublished\":\"2025-09-04T02:24:33+00:00\",\"dateModified\":\"2025-09-04T02:37:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/elementor.com\/tools\/color-palette-generator\/\"},\"wordCount\":5,\"keywords\":[\"Html-Css-tools\"],\"articleSection\":[\"tools\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/elementor.com\/tools\/color-palette-generator\/\",\"url\":\"https:\/\/elementor.com\/tools\/color-palette-generator\/\",\"name\":\"Color Palette Generator\",\"isPartOf\":{\"@id\":\"https:\/\/elementor.com\/tools\/#website\"},\"datePublished\":\"2025-09-04T02:24:33+00:00\",\"dateModified\":\"2025-09-04T02:37:05+00:00\",\"author\":{\"@id\":\"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac\"},\"description\":\"Effortlessly create stunning website color palettes with Elementor's free Website Color Palette Generator. Discover harmonious color schemes, refine shades, and get HEX codes for your design.\",\"breadcrumb\":{\"@id\":\"https:\/\/elementor.com\/tools\/color-palette-generator\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/elementor.com\/tools\/color-palette-generator\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/elementor.com\/tools\/color-palette-generator\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/elementor.com\/tools\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Color Palette Generator\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/elementor.com\/tools\/#website\",\"url\":\"https:\/\/elementor.com\/tools\/\",\"name\":\"Tools\",\"description\":\"Just another Elementor hosted website ;)\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/elementor.com\/tools\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac\",\"name\":\"liz@148.red\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/63b900d3310bd1ed40162fb27f016e9920ae66fa5be07be5153344329ef7d9d2?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/63b900d3310bd1ed40162fb27f016e9920ae66fa5be07be5153344329ef7d9d2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/63b900d3310bd1ed40162fb27f016e9920ae66fa5be07be5153344329ef7d9d2?s=96&d=mm&r=g\",\"caption\":\"liz@148.red\"},\"url\":\"https:\/\/elementor.com\/tools\/author\/liz148-red\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Color Palette Generator","description":"Effortlessly create stunning website color palettes with Elementor's free Website Color Palette Generator. Discover harmonious color schemes, refine shades, and get HEX codes for your design.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/elementor.com\/tools\/color-palette-generator\/","og_locale":"en_US","og_type":"article","og_title":"Color Palette Generator","og_description":"Effortlessly create stunning website color palettes with Elementor's free Website Color Palette Generator. Discover harmonious color schemes, refine shades, and get HEX codes for your design.","og_url":"https:\/\/elementor.com\/tools\/color-palette-generator\/","og_site_name":"Tools","article_published_time":"2025-09-04T02:24:33+00:00","article_modified_time":"2025-09-04T02:37:05+00:00","author":"liz@148.red","twitter_card":"summary_large_image","twitter_misc":{"Written by":"liz@148.red","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/elementor.com\/tools\/color-palette-generator\/#article","isPartOf":{"@id":"https:\/\/elementor.com\/tools\/color-palette-generator\/"},"author":{"name":"liz@148.red","@id":"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac"},"headline":"Color Palette Generator","datePublished":"2025-09-04T02:24:33+00:00","dateModified":"2025-09-04T02:37:05+00:00","mainEntityOfPage":{"@id":"https:\/\/elementor.com\/tools\/color-palette-generator\/"},"wordCount":5,"keywords":["Html-Css-tools"],"articleSection":["tools"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/elementor.com\/tools\/color-palette-generator\/","url":"https:\/\/elementor.com\/tools\/color-palette-generator\/","name":"Color Palette Generator","isPartOf":{"@id":"https:\/\/elementor.com\/tools\/#website"},"datePublished":"2025-09-04T02:24:33+00:00","dateModified":"2025-09-04T02:37:05+00:00","author":{"@id":"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac"},"description":"Effortlessly create stunning website color palettes with Elementor's free Website Color Palette Generator. Discover harmonious color schemes, refine shades, and get HEX codes for your design.","breadcrumb":{"@id":"https:\/\/elementor.com\/tools\/color-palette-generator\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/elementor.com\/tools\/color-palette-generator\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/elementor.com\/tools\/color-palette-generator\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/elementor.com\/tools\/"},{"@type":"ListItem","position":2,"name":"Color Palette Generator"}]},{"@type":"WebSite","@id":"https:\/\/elementor.com\/tools\/#website","url":"https:\/\/elementor.com\/tools\/","name":"Tools","description":"Just another Elementor hosted website ;)","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/elementor.com\/tools\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac","name":"liz@148.red","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/63b900d3310bd1ed40162fb27f016e9920ae66fa5be07be5153344329ef7d9d2?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/63b900d3310bd1ed40162fb27f016e9920ae66fa5be07be5153344329ef7d9d2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/63b900d3310bd1ed40162fb27f016e9920ae66fa5be07be5153344329ef7d9d2?s=96&d=mm&r=g","caption":"liz@148.red"},"url":"https:\/\/elementor.com\/tools\/author\/liz148-red\/"}]}},"_links":{"self":[{"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/posts\/8310138","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/comments?post=8310138"}],"version-history":[{"count":1,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/posts\/8310138\/revisions"}],"predecessor-version":[{"id":8310140,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/posts\/8310138\/revisions\/8310140"}],"wp:attachment":[{"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/media?parent=8310138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/categories?post=8310138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/tags?post=8310138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}