HackIndia Logo
HackathonsNewsSkillsGrowth
HackIndia LogoContact: +91 9910125804

General

  • Companies
  • Colleges
  • Board of Advisors
  • Brand Ambassadors
  • FAQ
  • Contact
  • Report a Bug

Hackathons

  • Upcoming Hackathons
  • Judges
  • Mentors
  • Partners
  • Participating Colleges
  • Testimonials

Resources

  • About Us
  • Branding
  • Latest News
  • Growth
  • Skills
  • Builders
  • Ecosystem
  • Forum
  • Ideas
  • Prompt Optimizer
  • Games

© 2026 HackIndia. All rights reserved.

Privacy PolicyTerms of ServiceCode of ConductSitemap

Build 2.139 · 05 Nov 2026, 10:27 UTC

    HackIndia
    HackathonsNewsInternshipsSkillsGrowthPro Perks
    Tailwind CSSWorking towardsTailwind CSS
    0%

    0 of 9 steps done · +100 XP · +50 SHARP when it is yours

    1. 1Think in utility classes4 min · +10 XP · +5 SHARP
    2. 2Use spacing and type scales5 min · +10 XP · +5 SHARP
    3. 3Build flex and grid layouts5 min · +10 XP · +5 SHARP
    4. 4Make it responsive first4 min · +10 XP · +5 SHARP
    5. 5Add useful dark mode4 min · +10 XP · +5 SHARP
    6. 6Keep classes readable4 min · +10 XP · +5 SHARP
    7. 7Submit a polished repo4 min · +10 XP · +5 SHARP
    8. The check10 questions, 7 to pass · +10 SHARP
    9. Hand in the taskA project that uses the skill
    10. Skill and certificate+100 XP · +50 SHARP
    Lesson 5 of 7 4 min

    Tailwind CSS

    Add useful dark mode

    • +10 XP for this lesson
    • +100 XP when the skill is proved
    • Nobody here has proved it yet
    In 30 seconds
    • Add dark mode styles with Tailwind’s dark: variant.
    • Choose between system dark mode and a manual toggle.
    Check contrast, borders, inputs, and empty states in both themes.
    Key point

    One idea

    Dark mode is not just a black background. It is a second pass on readability, contrast, borders, shadows, and form states.

    In Tailwind v4, use the dark: variant for classes that should change when dark mode is active.

    Default behaviour

    Tailwind’s dark mode uses the user’s system setting by default. If your laptop or phone is set to dark mode, dark: classes apply automatically.

    This is enough for many hackathon projects. A recruiter opening your Vite app should see a page that still looks finished in their preferred theme.

    Example

    Basic dark styling

    Start with the page shell. Then handle cards, text, borders, and buttons. These are the places where unfinished dark mode is easiest to spot.

    export default function App() {
      return (
        <main className="min-h-screen bg-slate-50 px-4 py-8 text-slate-900 dark:bg-slate-950 dark:text-slate-100">
          <section className="mx-auto max-w-3xl rounded-2xl border border-slate-200 bg-white p-6 shadow-sm dark:border-slate-800 dark:bg-slate-900">
            <p className="text-sm font-medium text-indigo-600 dark:text-indigo-400">
              Campus expense tracker
            </p>
    
            <h1 className="mt-3 text-3xl font-bold tracking-tight">
              Split mess bills without WhatsApp confusion
            </h1>
    
            <p className="mt-4 text-slate-600 dark:text-slate-300">
              Add shared expenses, track who paid, and settle with UPI.
            </p>
    
            <button className="mt-6 rounded-xl bg-indigo-600 px-4 py-2 font-medium text-white hover:bg-indigo-700 dark:bg-indigo-500 dark:hover:bg-indigo-400">
              Add expense
            </button>
          </section>
        </main>
      )
    }
    Your to-do

    Check these parts

    Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.

    0 of 5 done

    Common mistake

    Common mistake

    Do not use dark:bg-black everywhere. Pure black can make cards, inputs, and sections blend together.

    Use a small range like slate-950, slate-900, slate-800, and slate-300. This gives the page depth without custom CSS.

    Tip

    Use AI safely

    You can ask ChatGPT, Gemini, or Claude to add dark: classes to one component. Paste only that component, not your whole repo.

    Then check the output. Make sure it did not remove your responsive classes, change your logic, or add custom CSS you do not need.

    Prompt:
    Add useful Tailwind CSS v4 dark mode classes to this React component.
    Keep the existing layout and responsive classes.
    Do not add custom CSS.
    Return only the updated component.
    Example

    Manual toggle option

    If you want a theme switcher, override the dark variant in your main CSS. In Tailwind v4, the CSS entry point uses @import "tailwindcss".

    Older tutorials may show @tailwind base, @tailwind components, and @tailwind utilities. That is outdated for v4.

    @import "tailwindcss";
    @custom-variant dark (&:where(.dark, .dark *));
    
    /* Then add or remove the dark class on the html element */
    document.documentElement.classList.toggle("dark")
    Your to-do

    Do this now

    Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.

    0 of 5 done

    Sources

    Checked against the current documentation on 21 September 2026.

    • Dark mode · tailwindcss.com
    • Upgrade guide · tailwindcss.com

    Quick check

    0 of 2 right
    1.Your page has dark:bg-black on every section and cards are hard to see. What should you do?
    2.In Tailwind v4, what does dark: do by default?

    Answer the quick check to finish this lesson.

    ← Lesson 4Skip to lesson 6 →
    Tailwind CSS
    Working towards
    Tailwind CSS +100 XP

    0 of 7 lessons done · proved by a project that uses the skill

    See the track