Skip to content

A very minor bug related to the css #6809

Backlog

Description

@tirupati27

i have attached a 33 line textual code below, if you run and observe you can simply understand the problem.

the problem is-

going to the next screen and coming back to the home screen, it changes the bg color of the widget Label("black on cyan") which is unexpected.

but, when you replace the Label, Anything { background: red; } with Label { background: red; }, or Anything, Label { background: red; } it comes with the expected behaviour.

HERE IS THE CODE

from textual.app import App
from textual.screen import Screen
from textual.widgets import Label, Button


class MainApp(App):
    CSS = """
    Label { color: black; background: cyan; }
    """
    def compose(self):
        yield Label("black on cyan")
        yield Button("next-screen", variant='primary')

    def on_button_pressed(self, event: Button.Pressed):
        if str(event.button.label) == "next-screen":
            self.app.push_screen(Scr())


class Scr(Screen):
    CSS = """
    Label, Anything { background: red; }
    """
    def compose(self):
        yield Label("text with red bg")
        yield Button("pre-screen", variant='primary')

    def on_button_pressed(self, event: Button.Pressed):
        if str(event.button.label) == "pre-screen":
            self.dismiss()


if __name__ == "__main__":
    MainApp().run()

Activity

  1. github-actions commented on Dec 1, 2026

    @github-actions

    Thank you for your issue. Give us a little time to review it.

    PS. You might want to check the FAQ if you haven't done so already.

    This project is developed and maintained by Will McGugan. Consider sponsoring Will's work on this project (and others).

    This is an automated reply, generated by FAQtory

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions