Example of a theme switcher #852
Unanswered
marlonmarcello
asked this question in
Help
Replies: 2 comments 4 replies
-
This might help - I've been working on a ColorModeProvider and general "pattern" for handling this with stitches. Would love some feedback on it. I am building a design system that would be consumed by many different products, so was aiming for a portable way of providing the context / toggle functions "out of the box". it handles more than 2 modes Please let me know what you think - or any ideas! |
Beta Was this translation helpful? Give feedback.
3 replies
-
@lucastobrazil this is awesome, thanks so much!!!! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi! 👋
I was wondering if there is an example of a project with a theme switcher.
I read through all the docs and I think I understand how the
createTheme
works but the examples only show this:But for example how do I make it so my
darkMode
theme is used automatically if the user hasprefers-color-scheme: dark
? The example uses the theme on adiv
but how do I go about making it global by using thestyled
function?What if I wanted to have a theme switcher and let the user pick a theme how does that work?
As an example, coming from
styled-components
all I had to do was pass the theme to theThemeProvider
.I read the post about the differences between
stitches
andstyled-components
and in there it saysIn Stitches, you can define tokens in the config file and seamlessly consume and access directly in the Style Object.
but it doesn't show how to change between the themes.Beta Was this translation helpful? Give feedback.
All reactions