Skip to content

Day 2 — Making It Interactive

⏱️ Time needed: 30–45 minutes

🎯 Goal: Add a button that generates a brand new random palette every time you click it.


Yesterday you put colors on screen. Today you’re going to make them change. This is the moment your project goes from “a picture of a thing” to “an actual thing.”

In design terms: you’re moving from a static mockup to a working prototype. Except this prototype is the real product.


Right now your five swatches show hardcoded colors — they’re always the same. You’re going to add a button that, when clicked, picks five new random colors and updates the swatches instantly.

Think of it like hitting “shuffle” on a playlist, but for colors.


Add a button below the subtitle that says "Generate New Palette". Style it so it looks intentional — give it a dark background, white text, rounded corners, comfortable padding, and a hover state that slightly changes the background color. Center it on the page with some space between it and the swatches.

Preview it. You should see a nice-looking button. It won’t do anything yet — that’s the next step.


Now for the magic:

Make it so that when I click the "Generate New Palette" button, each swatch gets a new random color. The hex code displayed on each swatch should update to show the new color. The transition between colors should feel smooth — add a quick fade or color transition so it doesn't feel jarring.

Click the button. Click it again. And again.

You just built interactivity. Every click generates a completely new palette. The AI wrote the logic that picks random colors and updates the page — you just told it what you wanted to happen.


Good interaction design is about feel. Let’s refine:

When I hover over the Generate button, make the cursor change to a pointer. Add a subtle scale-up effect on hover (like 1.02x) so it feels responsive. When I click it, add a brief press-down effect. Also, add a smooth color transition to the swatches so when new colors appear, they blend in over about 0.3 seconds instead of snapping instantly.

These micro-interactions are what separate “works” from “feels good.” You already know this from your design work — now you’re applying it to code.


You don’t need to read the code in detail, but here’s the gist of what the AI created:

  • A button in the HTML (HyperText Markup Language) — the structure of your page
  • Styles in the CSS (Cascading Style Sheets) — how the button looks and animates
  • A bit of logic in JavaScript (often shortened to JS) — the part that says “when this button is clicked, do this thing”

JavaScript is what makes web pages interactive. It’s the layer that responds to clicks, updates content, and makes things move. You don’t need to write it from scratch — you just need to describe what you want to happen, and the AI handles the rest.


If you want to feel fancy:

Add a keyboard shortcut so pressing the spacebar also generates a new palette. Show a small hint text below the button that says "or press spacebar" in a subtle, muted color.

Now you can rapid-fire through palettes without even clicking. Satisfying, right?


  • How to add a button and make it trigger an action
  • How to describe interaction behavior (hover states, transitions, feedback) to an AI
  • That JavaScript is the “makes things happen” layer — and you don’t need to write it manually
  • That micro-interactions matter just as much in code as they do in design

You’ll add the ability to click on any swatch and copy its hex code to your clipboard. Because what good is a palette if you can’t use the colors?


🎯 Checkpoint: You should have a button that generates random palettes on click, with smooth color transitions on the swatches. If the colors change but feel abrupt, try: “The color changes are too sudden. Can you add a smooth transition so they fade to the new color over 0.3 seconds?”