Add abillity to prevent CssVarsProvider
from using local storage
#35837
Labels
customization: css
Design CSS customizability
package: styles
Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5.
Duplicates
Latest version
Summary 馃挕
The current implementation of
CssVarsProvider
requires the use of local storage to store the theme settings. My suggestion is to make the use of local storage optional. One idea is to add amode
property toCssVarsProvider
, in addition to the existingdefaultMode
property. With this new property, the theme would be controlled solely by the property and would not be affected by local storage. Another suggestion is to delay writing to local storage until the theme is explicitly changed using the setter of theuseColorScheme
hook. That way, if the setter is not used, nothing would be written to local storage.Examples 馃寛
No response
Motivation 馃敠
The current version of
CssVarsProvider
requires the use of local storage, even though it is unnecessary in certain situations. For example, if the theme is only controlled by the system theme, or if there is only one theme, there is no need to use local storage. Local storage adds unnecessary complexity due to statefulness. For example, it adds the need to check how divergent states in local storage and in code interact.The text was updated successfully, but these errors were encountered: