Skip to content

Commit

Permalink
docs: add FAQ on automatic dark mode
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 572601794
  • Loading branch information
asyncLiz authored and copybara-github committed Oct 11, 2023
1 parent ff250dc commit 19a2ea2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docs/support.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,31 @@ states.
Rather than setting all of them, or use the `--md-sys-color-*` token that the
component maps to (see the previous question).

### Why doesn't `prefers-color-scheme: dark` work?

It's up to the app to decide when and how dark mode is applied. Any selector can
be used with `--md-sys-color-*` dark theme tokens to scope how the changes
apply.

For example, using Sass:

```scss
@use '@material/web/color/color';

:root {
@media (prefers-color-scheme: dark) {
@include color.dark-theme;
}
}
```

> **Why not automatically?** Not all apps need dark mode, and the CSS size for
> automatically supporting it is much higher and not as flexible.
See
[How do I use `--md-sys-*` custom properties in my styles?](#how-do-i-use-md-sys-custom-properties-in-my-styles)
for more info on how to generate a set of dark theme tokens.

### How do I use `--md-sys-*` custom properties in my styles?

- Use Sass APIs.
Expand Down

0 comments on commit 19a2ea2

Please sign in to comment.