T
17

Old school hex codes vs CSS variables for dark themes

I used to hardcode every dark mode shade with hex values like #1a1a2e for backgrounds and #16213e for panels, but after a 60 page redesign last fall I switched everything to CSS custom properties. The change happened when I realized I was updating the same navy blue across 14 different files just to fix a contrast issue on mobile. Now I define a palette in one place and use semantic names like - bg-surface or - text-muted, which feels SO much easier to maintain. Is that just a crutch for lazy devs, or is there a real downside to relying on variables instead of locking in the exact values first?
0 comments

Log in to join the discussion

Log In
0 Comments

No comments yet

Be the first to share your thoughts on this discussion.