Colors in light and dark mode for macOS

The introduction of dark mode means that you’ll want to rely on the dynamic system colors where possible

Starting in macOS 10.14, the default appearance was joined by a dark appearance. Dark appearance not only changes the appearance of all the system controls and views, it also affects the appearance of the system colors.

NSColor provides nine standard system colors and these will adjust depending on which mode you are in.

Here are the colors for light and dark modes.

NSColor comes with 9 system colors that adjust automatically depending on

In most cases dark mode increases the brightness of each channel to make the color more vibrant against the dark background.

It’s preferable to use the system colors because not only do they automatically look good against a dark or light background, they also change if the user enables high contrast in the accessibility options.

Setting your own colors

When you do need to use your own colors asset catalogs provide a way to name colors for light and dark modes.

Asset catalogs let you specify colors for light, dark and high contrast

Referencing the color above in code is then easily done with:

NSColor.Name("LabelViewBackground")

Be aware that asset catalogs with colors only work when you’re targeting macOS 10.13 or above.

More articles about macOS development.