🦞 4minAI.com
1 / 20
Day 9 of 28 Β· Vibe Coding Challenge

Adding Interactivity

A static page is like a poster. It looks nice, but nobody can do anything with it. Today you turn your projects into things people can actually use β€” forms that submit, buttons that do things, content that responds to user actions.

What is interactivity?

Interactivity is anything that responds to a user's actions:

Click a button β†’ something happens (a modal opens, data saves, a page changes)

Type in a form β†’ validation appears, characters count, suggestions show up

Scroll the page β†’ animations trigger, sections reveal, a progress bar fills

Hover over an element β†’ it transforms, shows info, highlights

Toggle a switch β†’ dark mode activates, a setting saves, content filters

The difference between a "website" and a "web app" is interactivity. Today you cross that line.

Knowledge Check
What turns a static webpage into an interactive web application?
A
Using more CSS animations
B
Elements that respond to user actions β€” clicks, typing, scrolling, and other interactions
C
Adding more text content
D
Making it load faster
Interactivity means the page responds to what the user does. A blog post is static β€” it looks the same for everyone. A to-do app is interactive β€” users add, check off, and delete items. The page changes based on user actions.

Forms that actually work

Forms are the most common interactive element. Let's build one that does real validation.

πŸ€–
Cursor AI
online
Add a contact form to my landing page with these fields: name, email, message. Add real-time validation β€” name must be at least 2 characters, email must be valid format, message must be at least 10 characters. Show inline error messages in red below each field. Disable the submit button until all fields are valid. Show a success toast notification when submitted.
Contact form added βœ“ πŸ“ Three fields: name, email, message βœ… Real-time validation as the user types: - Name: "Must be at least 2 characters" - Email: "Please enter a valid email" - Message: "Must be at least 10 characters" πŸ”΄ Red error messages appear below invalid fields πŸ”’ Submit button stays disabled (grayed out) until all fields pass πŸŽ‰ Success toast slides in from the top when form submits Try filling out the form β€” validation triggers as you type.
↻ Replay conversation
Contact form with real-time validation β€” red error messages below invalid fields, disabled submit button
Real-time validation in action β€” errors appear as you type, not after you submit.
Knowledge Check
Why is real-time validation better than showing errors only after clicking submit?
A
It makes the form load faster
B
It uses less code
C
Users get immediate feedback and can fix issues as they type, instead of getting surprised after filling everything out
D
It's a technical requirement for forms
Real-time validation reduces frustration. Nobody likes filling out an entire form, clicking submit, and then being told their email was wrong. Instant feedback keeps users moving forward confidently.

Modals and popups

Modals are overlays that appear on top of the page β€” login forms, confirmations, image galleries, and more.

⚑
Bolt
online
Add a "Sign Up" button to the hero section. When clicked, it opens a modal with a sign-up form (name, email, password). The modal should have a blurred background overlay, smooth open/close animation, and close when clicking outside it or pressing Escape. Add a "Already have an account? Log in" link at the bottom of the modal.
Sign-up modal added βœ“ πŸ”΅ "Sign Up" button in hero section πŸ“¦ Modal with: - Name, email, password fields - Blurred background overlay - Fade + scale animation on open/close - Closes on overlay click or Escape key - "Already have an account? Log in" link ✨ Smooth animations throughout. Try clicking the button!
↻ Replay conversation

Dark mode toggle

Everyone expects dark mode now. It's also a perfect example of a toggle interaction.

πŸ€–
Cursor AI
online
Add a dark mode toggle to the navigation bar. Use a sun/moon icon that switches. The toggle should remember the user's preference (persist across page refreshes). Transition smoothly between light and dark themes β€” don't flash.
Dark mode added βœ“ πŸŒ™ Moon icon in nav bar (switches to β˜€οΈ sun in dark mode) πŸ’Ύ Preference saved in localStorage β€” persists across refreshes 🎨 Smooth 300ms transition on all colors ⚑ No flash on page load β€” checks saved preference before rendering Everything adapts: backgrounds, text, cards, borders, and form inputs.
↻ Replay conversation
Side-by-side comparison of the same landing page in light mode and dark mode, with sun and moon toggle icon visible
One prompt adds dark mode β€” toggle, persistence, smooth transition.
πŸ€–
Cursor AI
online
The footer looks weird in dark mode β€” the links are hard to read.
Fixed βœ“ Footer links now use a lighter gray (#A1A1AA) in dark mode with improved contrast. Hover state changes to white for clarity.
↻ Replay conversation
Knowledge Check
Why should a dark mode toggle "remember the user's preference"?
A
To save battery life
B
To make the code more complex
C
So users don't have to toggle it again every time they visit β€” their choice persists across sessions
D
To comply with accessibility laws
Persistence is about respecting the user's choice. If someone prefers dark mode, they shouldn't have to toggle it every time they visit your site. localStorage keeps that preference saved in their browser.

Animations and micro-interactions

Subtle animations make your project feel polished and professional. Here are the most impactful ones:

Scroll animations β€” Sections fade or slide in as you scroll down

Hover effects β€” Cards lift up, buttons change color, images zoom slightly

Loading states β€” Spinners, skeleton screens, progress bars while content loads

Transitions β€” Smooth changes between states instead of instant jumps

⚑
Bolt
online
Add these micro-interactions to my landing page: 1. Feature cards slide up and fade in when they enter the viewport 2. Numbers in the stats section count up from 0 when visible 3. The hero headline types itself out letter by letter 4. CTA buttons have a subtle scale effect on hover
Micro-interactions added βœ“ πŸ“¦ Feature cards β€” slide up + fade in on scroll (staggered timing) πŸ”’ Stats counter β€” numbers count up from 0 when section is visible ⌨️ Hero typewriter β€” headline types out letter by letter on page load πŸ”˜ CTA buttons β€” scale to 1.05x on hover with smooth transition The page feels alive now. Smooth and professional.
↻ Replay conversation
Knowledge Check
Which type of animation has the biggest impact on making a page feel professional?
A
3D rotating elements
B
Subtle micro-interactions β€” smooth transitions, gentle hover effects, and fade-in reveals
C
Flashy, attention-grabbing animations
D
Auto-playing video backgrounds
The best animations are felt, not noticed. Subtle transitions, gentle hover effects, and smooth reveal animations make a page feel polished without being distracting. Professional sites use restraint β€” every animation should serve a purpose.

Your turn

Take the landing page you built yesterday (or any project) and add at least three interactive elements:

1. A form with real-time validation

2. A toggle (dark mode, or anything that switches between two states)

3. Scroll-triggered animations

Each one teaches you a different interaction pattern. By the end, your page will feel like a real product.

Final Check
What turns a website from "nice looking" to "feels professional"?
A
More pages
B
Brighter colors
C
Thoughtful interactivity β€” smooth animations, responsive forms, persistent user preferences
D
More text content
Interactivity is the difference between a poster and a product. When forms validate in real-time, dark mode remembers your preference, and sections animate smoothly into view β€” that's when a page stops being a website and starts being an experience.
✨
Day 9 Complete
"A page that responds to you isn't a page β€” it's an experience. Now you know how to build one."
Tomorrow β€” Day 10
Working with APIs
Your apps will learn to talk to the outside world β€” pulling live data from real services and APIs.
πŸ”₯1
1 day streak!