Type Safely

Type Safely

Share this post

Type Safely
Type Safely
Detect Light or Dark Mode and Display Both Variations In Previews

Detect Light or Dark Mode and Display Both Variations In Previews

Daily Coding Tip 216

Type Safely's avatar
Type Safely
Nov 12, 2022
∙ Paid

Share this post

Type Safely
Type Safely
Detect Light or Dark Mode and Display Both Variations In Previews
Share
man standing in front of the window
Photo by Sasha Freemind on Unsplash

There is an environment variable that lets you access the currently selected colour scheme. There is currently only a light and dark mode, but it’s not impossible that new schemes will be introduced in the future.

For this reason I’ve used a switch on the variable with an @unknown default, so that I am prepared for th…

Keep reading with a 7-day free trial

Subscribe to Type Safely to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Type Safely
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share