Skip to content

Conversation

@ProH4Ck
Copy link
Contributor

@ProH4Ck ProH4Ck commented Oct 23, 2024

Pull Request

📖 Description

This pull request includes changes to improve theme management in the FluentDesignTheme component and updates to the CSS to support these changes.

A new data attribute (data-theme) is added to body and updated every time theme changes.

In reboot.css this attribute is used to control the value of color-scheme: this ensure all browser-managed components (like scrollbars) matches theme in use.

Before:

no_dark_mode_recognized

After:

all_dark

✅ Checklist

General

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

@dvoituron
Copy link
Collaborator

You can use a style like this to do the same thing... but maybe it's easier to add a body attribute.

@media (prefers-color-scheme: dark) {
    body {
        color-scheme: dark;
    }
}

@vnbaaij vnbaaij changed the title Apply global color-scheme to reflect theme in use [General] Apply global color-scheme to reflect theme in use Oct 24, 2024
@vnbaaij vnbaaij merged commit 456877a into microsoft:dev Oct 24, 2024
@ProH4Ck
Copy link
Contributor Author

ProH4Ck commented Oct 24, 2024

You can use a style like this to do the same thing... but maybe it's easier to add a body attribute.

@media (prefers-color-scheme: dark) {
    body {
        color-scheme: dark;
    }
}

The media query strategy only works if system theme is in use.
If the user switches to opposite theme (example: system is light, user switches to dark) media query is not updated and as result colors are inconsistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants