Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electron: useTheme's automatic prefers-color-scheme ignored #52

Open
McManning opened this issue Mar 17, 2023 · 2 comments
Open

Electron: useTheme's automatic prefers-color-scheme ignored #52

McManning opened this issue Mar 17, 2023 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers v5-alpha

Comments

@McManning
Copy link
Contributor

McManning commented Mar 17, 2023

Wrapping an Electron app with <RUIProvider> does not load the user-preferred color scheme. Doing it manually does work, however:

export default function App() {
  const prefersColorScheme = window.matchMedia('(prefers-color-scheme: dark)');

  return (
    <RUIProvider theme={prefersColorScheme?.matches ? 'dark' : 'light'}>
      <ThemeProvider theme={{}}>
        <Router>
          <Routes>
            ...
          </Routes>
        </Router>
      </ThemeProvider>
    </RUIProvider>
  );
}
@McManning McManning added bug Something isn't working v5-alpha labels Mar 17, 2023
@McManning McManning added the good first issue Good for newcomers label Mar 17, 2023
@Harikrishna3
Copy link

export default function App() {
const prefersColorScheme = window.matchMedia('(prefers-color-scheme: dark)');
const theme = React.useMemo(() => ({
mode: prefersColorScheme?.matches ? 'dark' : 'light'
}), [prefersColorScheme]);

return (




...




);
}

@Harikrishna3
Copy link

  <ThemeProvider theme={{}}>
    <Router>
      <Routes>
        ...
      </Routes>
    </Router>
  </ThemeProvider>
  </RUIProvider> 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers v5-alpha
Projects
None yet
Development

No branches or pull requests

2 participants