diff --git a/nicegui/elements/dark_mode.py b/nicegui/elements/dark_mode.py index 6deda2c96..e39301392 100644 --- a/nicegui/elements/dark_mode.py +++ b/nicegui/elements/dark_mode.py @@ -1,5 +1,6 @@ from typing import Optional +from .. import core, helpers from ..events import Handler, ValueChangeEventArguments from .mixins.value_element import ValueElement @@ -20,6 +21,19 @@ def __init__(self, value: Optional[bool] = False, *, on_change: Optional[Handler """ super().__init__(value=value, on_value_change=on_change) + # HACK: this is a temporary warning to inform users about issue #3753 + if core.app.is_started: + self._check_for_issue_3753() + else: + core.app.on_startup(self._check_for_issue_3753) + + def _check_for_issue_3753(self) -> None: + if self.client.page.resolve_dark() is None and core.app.config.tailwind: + helpers.warn_once( + '`ui.dark_mode` is not supported on pages with `dark=None` while running with `tailwind=True` (the default). ' + 'See https://github.com/zauberzeug/nicegui/issues/3753 for more information.' + ) + def enable(self) -> None: """Enable dark mode.""" self.value = True