fixing mantine provider scheme for local storage#681
fixing mantine provider scheme for local storage#681BSd3v wants to merge 3 commits intosnehilvj:masterfrom
Conversation
|
Thanks for the PR! |
|
I think it defaults to light, shouldnt need to add that. |
|
So, is this supposed to be used with theme switch components? What problem is this trying to solve? I didn't see any difference when setting the |
|
It actually works with the mantine local store, currently this is not the case as it doesn't update properly. |
|
OK, so for a theme switch should you do this? Try running it: import dash_mantine_components as dmc
from dash_iconify import DashIconify
from dash import Dash, Input, Output
theme_toggle = dmc.Switch(
offLabel=DashIconify(icon="radix-icons:sun", width=15, color=dmc.DEFAULT_THEME["colors"]["yellow"][8]),
onLabel=DashIconify(icon="radix-icons:moon", width=15, color=dmc.DEFAULT_THEME["colors"]["yellow"][6]),
id="color-scheme-switch",
persistence=True,
color="gray",
)
app = Dash()
app.layout = dmc.MantineProvider(
[theme_toggle, dmc.Text("Your page content")],
id="mantine-provider",
)
@app.callback(
Output("mantine-provider", "dashSetColorScheme"),
Input("color-scheme-switch", "checked"),
)
def update(checked):
if checked:
return "light"
return "dark"
if __name__ == "__main__":
app.run(debug=True) |
|
Try this app: This will also sync the app across multiple windows. We may need to allow for adjusting the storage listener and key in the component to allow custom defined stores. |
|
In the sample app above, I changed the |
|
Might be better to do this with a separate component. See #693 |
|
closed in favor of #693 |


No description provided.