Skip to content
Learn Netverks

Lesson

Step 31/36 86% through track

color-modes

Color modes (light / dark)

Last reviewed Jun 1, 2026 Content v20260601
Track mode
iframe_html
Means
HTML preview sandbox
Reading
~1 min
Level
advanced

This lesson

This lesson teaches Color modes (light / dark)—the ideas, syntax, and habits you need before moving on in Bootstrap.

Bootstrap patterns appear constantly in legacy apps and rapid admin UI work.

You will apply Color modes (light / dark) in contexts like: Internal tools, WordPress themes, Laravel apps, and teams that want opinionated UI without writing every rule from scratch.

Read the lesson, edit HTML/CSS in the playground, press Run to preview, then answer the lesson MCQs.

When intermediate lessons feel comfortable and you are ready for production-style trade-offs.

Bootstrap 5.3 adds first-class color modes. Set data-bs-theme="dark" on <html> or any subtree to swap component colors. Components pick up adjusted backgrounds, borders, and text without duplicate markup.

Toggles and persistence

Build a theme switcher that flips data-bs-theme between light and dark, then store preference in localStorage so return visits stay consistent. Respect prefers-color-scheme for the initial paint before JS runs.

Custom surfaces

Use bg-body, bg-body-secondary, and text-body instead of hard-coded bg-white when surfaces should adapt. Utility-first dark mode in Tailwind uses class prefixes—Bootstrap centralizes tokens at the theme root.

Self-check

  1. Which attribute switches a subtree to dark styling?
  2. Why prefer bg-body over bg-white in theme-aware layouts?
  3. How would you honor OS dark mode before JavaScript loads?

Interview prep

class vs data-bs-theme for dark mode?

data-bs-theme on a root element toggles CSS variables; can pair with color-mode scripts in BS 5.3.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • How would you test dark mode?
  • data-bs-theme vs class toggle?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump