-
-
Notifications
You must be signed in to change notification settings - Fork 602
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
Tailwind dark: prefix does not work #311
Comments
Good question! Currently I have no idea why it doesn't work. 😕 |
I just realized that we currently pass the nicegui/nicegui/templates/index.html Lines 147 to 148 in a23528a
Somehow we probably need to inform Tailwind about the mode we are in. |
And I noticed that |
Another step forward: Your default color ui.label('TEST').classes('text-red-400 dark:text-yellow-400') But: This only considers the current system settings, not the |
I added
But the label did not change when I flip my Dark switch. So looking at your changes, I edited my async def on_dark(event):
# HACK: Is that the proper way of switching dark mode?
js = '''
const dark = {value};
Quasar.Dark.set(dark === None ? "auto" : dark);
if (dark !== None) tailwind.config.darkMode = "class";
document.body.classList.remove("dark");
if (dark === True) document.body.classList.add("dark");
Quasar.Dark.isActive;
'''.replace('{value}', str(bool(event.value))) # .lower() is not required?
ret = await ui.run_javascript(js, respond=True)
info.log.push(f"Dark mode set to {ret}") And then everything seems to work. Perhaps the dark mode switching could be encapsulated in a JS function for reuse instead? And then, even better, exposed in nicegui API ;-) |
According to Tailwind documentation, we should be able to use classes such as
dark:text-yellow
, but it does not work.This shows red text on dark background.
Did I missed something?
The text was updated successfully, but these errors were encountered: