DEV Community

Discussion on: 🌟 Biggest “Online Tools” Collection: 10015.io 🧰

Collapse
 
sahez97 profile image
Sahz

Curious to know how are you implementing themes using styled-components?

Collapse
 
fatihtelis profile image
Fatih Telis

Hi Sahz, I'm using ThemeProvider of styled-components and all colors, typography, sizes, shadows etc. are passed as props to components.

Collapse
 
sahez97 profile image
Sahz

Doesn't ThemeProvider reduce performance of the app?
I went through a great article by Kent C.Dodds - epicreact.dev/css-variables/

He explains why using global css variables is more performant that using React context ThemeProvider

Thread Thread
 
fatihtelis profile image
Fatih Telis

Great article Sahz. I've read it before and why I'm still using the ThemeProvider approach is, there is no dark mode in my application, so there will be no re-render problem. Also, I'm not only sending colors, sizes etc. but also some helper functions and block styles from ThemeProvider which is not possible with CSS variables.