Skip to content

How to add a dark mode toggle? #2574

Answered by snide
tonyjmartinez asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @tonyjmartinez. This question is sort of out of scope for the library itself and is more a general React question so I'm closing this. EUI outputs compiled CSS files for light and dark as part of the dist, so there's no need to touch the Sass if you don't need. There's a couple different ways you could handle toggling that on and off with React.

The EUI docs itself have an example using a reducer https://github.com/elastic/eui/blob/master/src-docs/src/store/reducers/theme_reducer.js . Search eui for the theme*.js files and you'll see generally how it works

The EUi gatsby starter has a simpler example using context https://github.com/elastic/gatsby-eui-starter/blob/master/src/components…

Replies: 6 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by miukimiu
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@AlessandroStaffolani
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #2574 on November 11, 2020 17:48.