-
Notifications
You must be signed in to change notification settings - Fork 841
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
Lack of documentation on colorMode switching #5507
Comments
Hey @lightwave
We could do a better job explaining, but the no EUI components have yet been converted to take advantage of CSS-in-JS. As such, CSS-in-JS color mode switching will have no effect. You'll need to use a CSS/Sass method for color mode switching until components are converted. |
Hi @lightwave, As @thompsongl mentioned:
This answer can give you some ideas on how to achieve that using a CSS/Sass method: #2574 (comment). |
@lightwave root.render(
<React.StrictMode>
<EuiProvider colorMode='light'>
<App />
</EuiProvider>
</React.StrictMode>
); And unfortunately, import {
EuiHeader,
EuiHeaderSectionItem,
EuiHeaderLogo,
EuiHeaderLinks,
EuiHeaderLink,
} from '@elastic/eui';
import React from 'react'
export default function TopNav() {
return (
<EuiHeader>
<EuiHeaderSectionItem border="right">
<EuiHeaderLogo>Elastic</EuiHeaderLogo>
</EuiHeaderSectionItem>
<EuiHeaderSectionItem>
<EuiHeaderLinks aria-label="App navigation links example">
<EuiHeaderLink isActive>Docs</EuiHeaderLink>
<EuiHeaderLink>Code</EuiHeaderLink>
<EuiHeaderLink iconType="help">Help</EuiHeaderLink>
</EuiHeaderLinks>
</EuiHeaderSectionItem>
</EuiHeader>
)
} Still ends defaulting to dark mode, why??? @thompsongl Do we have a way to fix this? Under normal working circumstances, I assume a framework should adapt to the provider config and should only change if explicitly told so through eight component props e.t.c I would appreciate your help on this. |
@blessedjasonmwanza How are you importing the CSS styles? EUI is currently in the process of moving towards a complete CSS-in-JS themed library, but we haven't converted all components including the EuiHeader (you can track the meta ticket here: #5685). If you follow the guidelines set here: https://elastic.github.io/eui/#/guidelines/getting-started#setting-up-your-application you should see an |
Thanks a million, @cchaos . In react: import '@elastic/eui/dist/eui_theme_light.css'; Imported in each component seems to resolve the issue. I appreciate your prompt assistance.
|
I'd hope that isn't truly necessary. You should have something like |
Oh, yea 🥇 . You just saved my brain from creating chaos 🙈 . Thanks a lot, @cchaos /> |
I tried using lazy & suspense to switch dynamically between dark & light themes, but CSS is broken (some components stay in dark and vice-versa): Here what I did, datatok/gui#13
|
I took a look at our docs because we've been improving them over time. And we still don't reference properly how to toggle between light and dark themes. We just say here that we should include the correspondent Then in the provider or color mode section, we never reference that the This issue will be resolved once we convert all components to emotion. No more
|
Actually, I'm closing this issue in favor of #5072. |
My apology if there is documentation on switch between light/dark colorMode but I couldn't find it on the eui documentation site.
Passing colorMode="dark" to EuiProvider doesn't switch it to dark mode. What's the recommended way to set up light/dark mode switching? I don't think I should import both light and dark css files.
Thanks for any clarification.
The text was updated successfully, but these errors were encountered: