{"id":8310121,"date":"2025-09-04T04:32:25","date_gmt":"2025-09-04T01:32:25","guid":{"rendered":"https:\/\/elementor.com\/tools\/?p=8310121"},"modified":"2025-09-04T04:34:15","modified_gmt":"2025-09-04T01:34:15","slug":"random-color-palette-generator","status":"publish","type":"post","link":"https:\/\/elementor.com\/tools\/random-color-palette-generator\/","title":{"rendered":"Random Color Palette Generator"},"content":{"rendered":"\t\t<div data-elementor-type=\"container\" data-elementor-id=\"8310122\" class=\"elementor elementor-8310122\" 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 provided code --- *\/\r\n    .color-palette-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 24px;\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; \/* Added for softer edges *\/\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    \/* Using your #minifyBtn style for the primary action *\/\r\n    #generateBtn {\r\n        background-color: #ff7be5;\r\n        color: black;\r\n        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);\r\n    }\r\n\r\n    #generateBtn:is(:hover, :focus, :focus-visible, :active) {\r\n        background-color: #ffa8ee;\r\n        transform: translateY(-2px);\r\n        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);\r\n    }\r\n\r\n    .copy-btn {\r\n        background-color: rgba(255, 255, 255, 0.7);\r\n        color: black;\r\n        border: none;\r\n        padding: 6px 10px;\r\n        border-radius: 4px;\r\n        cursor: pointer;\r\n        font-size: 14px;\r\n        display: flex;\r\n        align-items: center;\r\n        gap: 6px;\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, 1);\r\n    }\r\n\r\n    \/* This is the main container for the color swatches *\/\r\n    .main-content {\r\n        display: flex;\r\n        gap: 20px;\r\n        justify-content: center;\r\n        align-items: center;\r\n        flex-wrap: wrap;\r\n        margin-top: 40px;\r\n    }\r\n\r\n    \/* --- New styles for the color palette tool --- *\/\r\n    .color-swatch {\r\n        background-color: #ffffff;\r\n        border: 1px solid #EBEBEB;\r\n        border-radius: 8px;\r\n        overflow: hidden;\r\n        box-shadow: 0 2px 10px rgba(0,0,0,0.08);\r\n        transition: transform 0.2s ease-in-out;\r\n        width: 180px;\r\n    }\r\n\r\n    .color-swatch:hover {\r\n        transform: translateY(-5px);\r\n        box-shadow: 0 5px 15px rgba(0,0,0,0.12);\r\n    }\r\n\r\n    .color-display {\r\n        height: 150px;\r\n        width: 100%;\r\n        transition: background-color 0.3s;\r\n    }\r\n\r\n    .color-info {\r\n        padding: 12px;\r\n        display: flex;\r\n        justify-content: space-between;\r\n        align-items: center;\r\n        background-color: #ffffff;\r\n    }\r\n\r\n    .hex-code {\r\n        font-family: 'Courier New', monospace;\r\n        font-weight: 600;\r\n        font-size: 1rem;\r\n        color: #333;\r\n    }\r\n    \r\n    .copy-btn svg {\r\n        width: 16px;\r\n        height: 16px;\r\n    }\r\n    \r\n    \/* Reusing your success message style *\/\r\n    .success-message {\r\n        position: fixed;\r\n        bottom: 20px; \/* Changed from top to bottom *\/\r\n        right: 20px;\r\n        background-color: #28a745;\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        transform: translateY(100px); \/* Changed direction *\/\r\n        transition: all 0.4s cubic-bezier(0.215, 0.610, 0.355, 1); \/* Smoother transition *\/\r\n        z-index: 1000;\r\n        box-shadow: 0 0 15px rgba(0,0,0,0.2);\r\n    }\r\n\r\n    .success-message.show {\r\n        opacity: 1;\r\n        transform: translateY(0);\r\n    }\r\n\r\n    \/* Responsive adjustments *\/\r\n    @media (max-width: 1024px) {\r\n        .main-content {\r\n            gap: 15px;\r\n        }\r\n        .color-swatch {\r\n            width: 160px;\r\n        }\r\n    }\r\n    \r\n    @media (max-width: 768px) {\r\n        .color-palette-app {\r\n            padding: 30px 10px;\r\n        }\r\n        .main-content {\r\n           gap: 20px;\r\n        }\r\n       .color-swatch {\r\n            width: calc(50% - 10px); \/* Two columns on mobile *\/\r\n            max-width: 180px;\r\n        }\r\n    }\r\n<\/style>\r\n\r\n<div id=\"colorPaletteApp\" class=\"color-palette-app\">\r\n    \r\n    <!-- Using your button container class for consistency -->\r\n    <div class=\"format-btn-container\">\r\n        <button id=\"generateBtn\" class=\"format-btn\">Generate New Palette<\/button>\r\n    <\/div>\r\n\r\n    <!-- The main content area where color swatches will be inserted by JS -->\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 element -->\r\n    <div id=\"successMessage\" class=\"success-message\">Color code copied!<\/div>\r\n<\/div>\r\n\r\n<script>\r\n    \/\/ Self-invoking function to avoid polluting the global scope\r\n    (function() {\r\n        \/\/ --- DOM Element Selection ---\r\n        const generateBtn = document.getElementById('generateBtn');\r\n        const paletteContainer = document.getElementById('paletteContainer');\r\n        const successMessage = document.getElementById('successMessage');\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 '#1a2b3c'.\r\n         *\/\r\n        function generateRandomColor() {\r\n            \/\/ Using padStart to ensure the color code is always 6 characters long\r\n            const randomColor = '#' + Math.floor(Math.random() * 16777215).toString(16).padStart(6, '0');\r\n            return randomColor;\r\n        }\r\n\r\n        \/**\r\n         * Clears the palette and generates a new set of color swatches.\r\n         *\/\r\n        function generatePalette() {\r\n            \/\/ Clear any existing colors\r\n            paletteContainer.innerHTML = ''; \r\n\r\n            for (let i = 0; i < PALETTE_SIZE; i++) {\r\n                const colorHex = generateRandomColor();\r\n                \r\n                \/\/ Create the HTML structure for a single color swatch\r\n                const colorSwatch = document.createElement('div');\r\n                colorSwatch.className = 'color-swatch';\r\n\r\n                colorSwatch.innerHTML = `\r\n                    <div class=\"color-display\" style=\"background-color: ${colorHex};\"><\/div>\r\n                    <div class=\"color-info\">\r\n                        <span class=\"hex-code\">${colorHex.toUpperCase()}<\/span>\r\n                        <button class=\"copy-btn\" data-color=\"${colorHex}\">\r\n                            <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\" ry=\"2\"><\/rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"><\/path><\/svg>\r\n                        <\/button>\r\n                    <\/div>\r\n                `;\r\n                paletteContainer.appendChild(colorSwatch);\r\n            }\r\n        }\r\n\r\n        \/**\r\n         * Copies the provided text to the clipboard and shows a success message.\r\n         * @param {string} textToCopy - The text to be copied.\r\n         *\/\r\n        async function copyToClipboard(textToCopy) {\r\n            try {\r\n                await navigator.clipboard.writeText(textToCopy);\r\n                showSuccessMessage();\r\n            } catch (err) {\r\n                console.error('Failed to copy text: ', err);\r\n                alert('Failed to copy color code.');\r\n            }\r\n        }\r\n\r\n        \/**\r\n         * Displays the success message for a short duration.\r\n         *\/\r\n        function showSuccessMessage() {\r\n            successMessage.classList.add('show');\r\n            setTimeout(() => {\r\n                successMessage.classList.remove('show');\r\n            }, 2000); \/\/ Message will be visible for 2 seconds\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 to handle clicks on any copy button inside the container\r\n        paletteContainer.addEventListener('click', function(event) {\r\n            const copyButton = event.target.closest('.copy-btn');\r\n            if (copyButton) {\r\n                const colorToCopy = copyButton.dataset.color;\r\n                copyToClipboard(colorToCopy);\r\n            }\r\n        });\r\n\r\n        \/\/ --- Initial Load ---\r\n        \/\/ Generate a palette as soon as the page loads\r\n        generatePalette();\r\n\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-8310121","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>Random Color Palette Generator<\/title>\n<meta name=\"description\" content=\"Instantly generate unlimited random color palettes with HEX codes. Perfect for web design, branding, art, and more. Get your free color inspiration now!\" \/>\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\/random-color-palette-generator\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Random Color Palette Generator\" \/>\n<meta property=\"og:description\" content=\"Instantly generate unlimited random color palettes with HEX codes. Perfect for web design, branding, art, and more. Get your free color inspiration now!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/elementor.com\/tools\/random-color-palette-generator\/\" \/>\n<meta property=\"og:site_name\" content=\"Tools\" \/>\n<meta property=\"article:published_time\" content=\"2025-09-04T01:32:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-04T01:34:15+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\/random-color-palette-generator\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/elementor.com\/tools\/random-color-palette-generator\/\"},\"author\":{\"name\":\"liz@148.red\",\"@id\":\"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac\"},\"headline\":\"Random Color Palette Generator\",\"datePublished\":\"2025-09-04T01:32:25+00:00\",\"dateModified\":\"2025-09-04T01:34:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/elementor.com\/tools\/random-color-palette-generator\/\"},\"wordCount\":6,\"keywords\":[\"Html-Css-tools\"],\"articleSection\":[\"tools\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/elementor.com\/tools\/random-color-palette-generator\/\",\"url\":\"https:\/\/elementor.com\/tools\/random-color-palette-generator\/\",\"name\":\"Random Color Palette Generator\",\"isPartOf\":{\"@id\":\"https:\/\/elementor.com\/tools\/#website\"},\"datePublished\":\"2025-09-04T01:32:25+00:00\",\"dateModified\":\"2025-09-04T01:34:15+00:00\",\"author\":{\"@id\":\"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac\"},\"description\":\"Instantly generate unlimited random color palettes with HEX codes. Perfect for web design, branding, art, and more. Get your free color inspiration now!\",\"breadcrumb\":{\"@id\":\"https:\/\/elementor.com\/tools\/random-color-palette-generator\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/elementor.com\/tools\/random-color-palette-generator\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/elementor.com\/tools\/random-color-palette-generator\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/elementor.com\/tools\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Random 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":"Random Color Palette Generator","description":"Instantly generate unlimited random color palettes with HEX codes. Perfect for web design, branding, art, and more. Get your free color inspiration now!","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\/random-color-palette-generator\/","og_locale":"en_US","og_type":"article","og_title":"Random Color Palette Generator","og_description":"Instantly generate unlimited random color palettes with HEX codes. Perfect for web design, branding, art, and more. Get your free color inspiration now!","og_url":"https:\/\/elementor.com\/tools\/random-color-palette-generator\/","og_site_name":"Tools","article_published_time":"2025-09-04T01:32:25+00:00","article_modified_time":"2025-09-04T01:34:15+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\/random-color-palette-generator\/#article","isPartOf":{"@id":"https:\/\/elementor.com\/tools\/random-color-palette-generator\/"},"author":{"name":"liz@148.red","@id":"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac"},"headline":"Random Color Palette Generator","datePublished":"2025-09-04T01:32:25+00:00","dateModified":"2025-09-04T01:34:15+00:00","mainEntityOfPage":{"@id":"https:\/\/elementor.com\/tools\/random-color-palette-generator\/"},"wordCount":6,"keywords":["Html-Css-tools"],"articleSection":["tools"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/elementor.com\/tools\/random-color-palette-generator\/","url":"https:\/\/elementor.com\/tools\/random-color-palette-generator\/","name":"Random Color Palette Generator","isPartOf":{"@id":"https:\/\/elementor.com\/tools\/#website"},"datePublished":"2025-09-04T01:32:25+00:00","dateModified":"2025-09-04T01:34:15+00:00","author":{"@id":"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac"},"description":"Instantly generate unlimited random color palettes with HEX codes. Perfect for web design, branding, art, and more. Get your free color inspiration now!","breadcrumb":{"@id":"https:\/\/elementor.com\/tools\/random-color-palette-generator\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/elementor.com\/tools\/random-color-palette-generator\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/elementor.com\/tools\/random-color-palette-generator\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/elementor.com\/tools\/"},{"@type":"ListItem","position":2,"name":"Random 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\/8310121","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=8310121"}],"version-history":[{"count":1,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/posts\/8310121\/revisions"}],"predecessor-version":[{"id":8310125,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/posts\/8310121\/revisions\/8310125"}],"wp:attachment":[{"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/media?parent=8310121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/categories?post=8310121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/tags?post=8310121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}