Type Safely

Type Safely

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
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…

User's avatar

Continue reading this post for free, courtesy of Type Safely.

Or purchase a paid subscription.
© 2026 Type Safely · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture