diff --git a/src/textual/app.py b/src/textual/app.py index 1462eeb3ef..3578e2d751 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -480,7 +480,14 @@ def watch_dark(self, dark: bool) -> None: """Watches the dark bool.""" self.set_class(dark, "-dark-mode") self.set_class(not dark, "-light-mode") - self.refresh_css() + try: + self.refresh_css() + except ScreenStackError: + # It's possible that `dark` can be set before we have a default + # screen, in an app's `on_load`, for example. So let's eat the + # ScreenStackError -- the above styles will be handled once the + # screen is spun up anyway. + pass def get_driver_class(self) -> Type[Driver]: """Get a driver class for this platform.