mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
94.02k stars 32.3k forks source link

[feat] ability to change theme at runtime? #44470

Open JounQin opened 2 days ago

JounQin commented 2 days ago

Summary

Is that possible to change theme at runtime? For example we need to sync our website's theme with our other websites which could be changed by users manually, so we need to fetch the theme first and then generate the theme at runtime.

Examples

No response

Motivation

No response

Search keywords: runtime theme

sai6855 commented 2 days ago

@JounQin In following demo, i've changed button's variant in theme at runtime. is this what you are looking for?

https://stackblitz.com/edit/react-jhvgqn?file=Demo.tsx

DiegoAndai commented 16 hours ago

Hey @JounQin! Thanks for the report.

Are you using Emotion of Pigment CSS as a styling engine? If it's Emotion, then @sai6855's example should work for you.