Change record status: 
Project: 
Introduced in branch: 
Introduced in version: 
Description: 

Drupal stores a color scheme preference for each user account.

Before

Core had no color scheme preference. The default admin theme had its own dark mode setting.

After

The user entity has a new color_scheme base field. The values are auto, light and dark. The default is auto, which follows the operating system setting. Users pick a value on their profile form, under "User settings".

AccountInterface::getColorScheme() returns the value for the current user.

ThemePreprocess::preprocessHtml() adds two things:

data-color-scheme on the <html> element,
a color_scheme variable for html.html.twig.

HTML pages vary by the new user.color_scheme cache context.

The dark mode setting in the default_admin theme was removed.

Themes can use the attribute or the variable to apply the preference. This change adds no theme CSS, so no theme applies the preference yet.

user_update_11101() installs the field on existing sites.

Impacts: 
Site builders, administrators, editors
Themers
Site templates, recipes and distribution developers