Skip to content

Conversation

yorickvP
Copy link

@yorickvP yorickvP commented Oct 2, 2025

This PR adds support for the color palette update notifications protocol. Changing the terminal color theme will generate a Messages.TerminalColorTheme, and one will be generated at the start.

This can be used to implement auto light/dark theme switching.
In the future, this could be extended to the web and to implement automatic theme switching inside textual (maybe using TEXTUAL_THEME=dark=textual-dark,light=textual-light or something similar).

Please review the following checklist.

  • Docstrings on all new or modified functions / classes
  • Updated documentation
  • Updated CHANGELOG.md (where appropriate)

@yorickvP
Copy link
Author

yorickvP commented Oct 2, 2025

I'm using this in my own app with

class TApp(App):
    def on_terminal_color_theme(self, message: TerminalColorTheme):
        match message.theme:
            case "light":
                self.theme = "catppuccin-latte" # "textual-light"
            case "dark":
                self.theme = "catppuccin-mocha" # "textual-dark"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant