Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[material-ui] Add storageManager prop to ThemeProvider #45136

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented Jan 29, 2025

closes #35837

  • Implementation and tests
  • Update docs

Changes

  • Added new prop storageManager to the ThemeProvider. The use cases I see:
    • Disable the storage behavior by providing storageManager={null}
    • Change the storage from localStorage to a custom one e.g. cookies.
  • Extract localStorage logic to localStorageManager.
  • Export type StorageManger from @mui/material/styles so user can create a custom one with type safety.

@siriwatknp siriwatknp added package: system Specific to @mui/system package: material-ui Specific to @mui/material labels Jan 29, 2025
@mui-bot
Copy link

mui-bot commented Jan 29, 2025

Netlify deploy preview

@material-ui/core: parsed: +0.04% , gzip: +0.09%
@mui/joy: parsed: +0.05% , gzip: +0.10%
@material-ui/system: parsed: +0.28% , gzip: +0.41%

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 6db206c

@oliviertassinari oliviertassinari changed the title [material-ui] Add storageManager prop to ThemeProvider. [material-ui] Add storageManager prop to ThemeProvider Jan 29, 2025
@siriwatknp siriwatknp marked this pull request as ready for review January 31, 2025 07:49
</ThemeProvider>
);
}
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also include an example of how to turn it off entirely with storageManager={null}, including the consequences of doing so.

Copy link
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should cherry-pick this to v6.x

@siriwatknp siriwatknp force-pushed the provider/custom-storage branch from aa7c1c2 to b020037 Compare February 26, 2025 09:54
Copy link
Contributor

@mapache-salvaje mapache-salvaje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor notes on the text here, otherwise the docs additions look good.

@DiegoAndai DiegoAndai added v6.x needs cherry-pick The PR should be cherry-picked to master after merge labels Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs cherry-pick The PR should be cherry-picked to master after merge package: material-ui Specific to @mui/material package: system Specific to @mui/system v6.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add abillity to prevent CssVarsProvider from using local storage
5 participants