Skip to content

Scrollbars appear to ignore the background colour percentage #5458

Closed
@davep

Description

@davep

Each of the scrollbar styles say that they take a percentage that is the opacity to use. However, it appears that this value gets ignored. With this code:

from textual.app import App, ComposeResult
from textual.containers import VerticalScroll
from textual.widgets import Static

class ScrollBarPercentageApp(App[None]):

    CSS = """
    Screen {
        layout: horizontal;
    }

    VerticalScroll {
        scrollbar-size-vertical: 10;

        &#no-pcent {
            background: $surface;
            scrollbar-background: $surface;
            scrollbar-background-active: $surface;
            scrollbar-background-hover: $surface;
        }

        &#pcent {
            background: $surface 10%;
            scrollbar-background: $surface 10%;
            scrollbar-background-active: $surface 10%;
            scrollbar-background-hover: $surface 10%;
        }
    }
    """

    def compose(self) -> ComposeResult:
        with VerticalScroll(id="no-pcent"):
            yield Static(
                "\n".join(
                    f"This is some text {n}" for n in range(100)
                )
            )
        with VerticalScroll(id="pcent"):
            yield Static(
                "\n".join(
                    f"This is some text {n}" for n in range(100)
                )
            )

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

the result is this:

Screenshot 2025-01-06 at 11 30 51

Note that on the left the scrollbar background and the container are set to $surface and they match; on the right they're set to $surface 10% and they don't match, which the scrollbar background appearing to still be just $surface.

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