Dark mode revisited

I added a dark mode to my website a while back. It was a fun thing to do during Indie Web Camp Amsterdam last year.

I tied the colour scheme to the operating system level. If you choose a dark mode in your OS, my website will adjust automatically thanks to the prefers-color-scheme: dark media query.

But I’ve seen notes from a few friends, not about my site specifically, but about how they like having an explicit toggle for dark mode (as well as the media query). Whenever I read those remarks, I’d think “I’m really not sure I’ve got time to deal with adding that kind of toggle to my site.”

But then I realised, “Jeremy, you absolute muffin! You’ve had a theme switcher on your website for almost two decades now!”

Doh! I had forgotten about that theme switcher. It dates back to the early days of CSS. I wanted my site to be a demonstration of how you could apply different styles to the same underlying markup (this was before the CSS Zen Garden came along). Those themes are very dated now, but if you like you can view my site with a Zeldman theme or a sci-fi theme.

To offer a dark-mode theme for my site, all I had to do was take the default stylesheet, pull out the custom properties from the prefers-color-scheme: dark media query, and done. It took less than five minutes.

So if you want to view my site in dark mode, it’s one of the options in the “Customise” dropdown on every page of the website.

Responses

Related posts

Displaying HTML web components

You might want to use `display: contents` …maybe.

Who knows?

Had you heard of these bits of CSS? Me too/neither!

Schooltijd

Going back to school in Amsterdam.

Control

Trying to understand a different mindset to mine.

Talking about style

The transcript of a talk.

Related links

It’s about time I tried to explain what progressive enhancement actually is - Piccalilli

Progressive enhancement is a design and development principle where we build in layers which automatically turn themselves on based on the browser’s capabilities.

The idea of progressive enhancement is that everyone gets the perfect experience for them, rather than a pre-determined “perfect” experience from a design and development team.

Tagged with

New magic for animations in CSS | Chase McCoy

Hallelujah! We’re finally getting our two wishes for CSS animations and transitions:

  1. Animating to and from display: none; for the sake of enter/exit animations.
  2. Animating to and from the intrinsic size of an element (such as height: auto;).

Tagged with

Printing music with CSS grid

Laying out sheet music with CSS grid—sounds extreme until you see it abstracted into a web component.

We need fluid and responsive music rendering for the web!

Tagged with

An Interactive Guide to CSS Container Queries

Another terrific interactive tutorial from Ahmad, this time on container queries.

Tagged with

How would you build Wordle with just HTML and CSS? | Scott Jehl, Web Designer/Developer

This is a great thought exercise in progressive enhancement …that Scott then turns into a real exercise!

Tagged with

Previously on this day

8 years ago I wrote Unlabelled search fields

A look at some of the accessibility options.

9 years ago I wrote 100 × 100

Writing about writing.

16 years ago I wrote dConstructicon

Get your ticket while the server’s up.

18 years ago I wrote The unpushed envelope

Isn’t it high time we started using CSS to its fullest?

19 years ago I wrote Live 8: music, politics and network theory

I have just one or two things I need to get off my chest and then I’ll stop banging on about Live 8.

19 years ago I wrote That was Live 8

I couldn’t take any more punishment. The cumulative effect of Joss Stone, The Scissor Sisters and Velvet Revolver drove me out of Hyde Park. If I had stuck around to endure the pain of Robbie Williams and Mariah Carey, I fear that my exploding head

20 years ago I wrote Have t-shirt, will travel

I just finished coding an e-commerce site with Message. The Rapha website, selling cycling apparel, has launched just in time for the Tour de France.

22 years ago I wrote Home

I’m back and I’m tired.