Skip to content

Commit

Permalink
show warning when ui.dark_mode breaks Tailwind
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Nov 15, 2024
1 parent 0f1e38e commit 5cff7c7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions nicegui/elements/dark_mode.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Optional

from .. import background_tasks, core, helpers
from ..events import Handler, ValueChangeEventArguments
from .mixins.value_element import ValueElement

Expand All @@ -19,6 +20,14 @@ def __init__(self, value: Optional[bool] = False, *, on_change: Optional[Handler
:param on_change: Callback that is invoked when the value changes.
"""
super().__init__(value=value, on_value_change=on_change)
background_tasks.create(self._check_for_issue_3753())

async 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."""
Expand Down

0 comments on commit 5cff7c7

Please sign in to comment.