Skip to content

Is there a way to use $boost, $accent, $panel inside of python code? #5146

Discussion options

You must be logged in to vote

The problem is that the background style expects a <color> format, which doesn't include Textual's CSS variables.

I don't know if this is the "proper" way, but using the App.get_css_variables method seems to work for most Textual colors, apart from the $boost due to the alpha channel.

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

COLOR_NAMES = [
    "primary",
    "secondary",
    "background",
    "primary-background",
    "secondary-background",
    "surface",
    "panel",
    "boost",
    "warning",
    "error",
    "success",
    "accent",
]


class ExampleApp(App):
    CSS = """
    Static {
        height: 3;

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by edward-jazzhands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants