03. Capstone Project: Dark Mode Developer Portfolio

🔴 Advanced

1. Definition

This capstone project guides you through building a Modern Developer Portfolio featuring light/dark theme switching using CSS custom properties, BEM methodology, project card grids, and smooth scroll anchor behavior.

2. Why It Is Used

Building a personal portfolio allows developers to showcase projects, demonstrate CSS architecture skills, and highlight mastery of modern CSS themeing.

3. How It Works

CSS custom properties (e.g. --bg-primary) are declared at :root level and overridden under @media (prefers-color-scheme: dark) or a [data-theme="dark"] attribute.

4. Syntax

:root {
  color-scheme: light dark;
  --bg-primary: #ffffff;
  --text-primary: #0f172a;
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --text-primary: #f8fafc;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.3s, color 0.3s;
}

5. Portfolio BEM Architecture Table

BEM SelectorComponent Role
.portfolio-heroBlock: Hero header wrapper
.portfolio-hero__avatarElement: Profile avatar image
.project-card--featuredModifier: Highlighted project item

6. Beginner Example

html {
  scroll-behavior: smooth;
}

7. Intermediate Example

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

8. Advanced Theme Switcher Code

.theme-toggle-btn {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--text-primary);
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.3s;
}

9. Line-by-Line Code Explanation

  • html { scroll-behavior: smooth; }: Enables smooth animated scrolling when users click internal page navigation links (e.g. #projects).

10. Expected Terminal / Browser Output

A developer portfolio featuring an automatic dark mode theme toggle, smooth anchor scrolling, and responsive project cards.

11. Common Mistakes & Pitfalls

  • Hardcoding HEX colors inside component rules: Hardcoding colors in card classes breaks dark mode theme switching. Always reference CSS variables (var(--text-primary)).

12. Important Rules & Limitations

  • Always set color-scheme: light dark so standard form controls and scrollbars match dark mode themes.

13. Multilingual Explanation: English

This project uses CSS variables, BEM architecture, and smooth scrolling to build a modern developer portfolio with dark mode support.

14. Multilingual Explanation: Hindi (Roman Script)

CSS variables aur dark mode theme switching se modern developer portfolio banana sikhata hai.

15. Multilingual Explanation: Marathi (Roman Script)

CSS variables ani dark mode themeing sathi developer portfolio project banva.

16. Practice Questions

  1. Why does referencing CSS variables instead of hardcoded colors make theme switching instantaneous?

17. Practical Coding Challenge

Add a [data-theme="dark"] attribute selector block to your stylesheet and customize dark mode card background colors.

18. Related Topics