Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS parsing breaks when using border: $text #3025

Closed
eliasdorneles opened this issue Jul 27, 2023 · 4 comments
Closed

CSS parsing breaks when using border: $text #3025

eliasdorneles opened this issue Jul 27, 2023 · 4 comments

Comments

@eliasdorneles
Copy link

I wanted to create a widget with a border the same color as the text.

However, when I tried using border: solid $text I get this error:

image

Other color names like $primary, $secondary, etc; these work fine, but for some reason it breaks for $text.

Here is a simplified example that demonstrates the issue:

from textual.app import App, ComposeResult
from textual.widgets import Label


class MyApp(App):
    CSS = """
    Screen Label {
        border: solid $text;
    }
    """

    def compose(self) -> ComposeResult:
        yield Label("Hello, world!")


if __name__ == "__main__":
    app = MyApp()
    app.run()

This should work, right?

@github-actions
Copy link

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 is an automated reply, generated by FAQtory

@TomJGooding
Copy link
Contributor

TomJGooding commented Jul 27, 2023

From the docs it looks like $primary and $secondary are part of the 12 base colors, whereas $text only works with the color property for setting text color..

For example background: $text won't work either. I agree it would be useful to allow easily setting other elements like the border the same color as the text.

@willmcgugan
Copy link
Collaborator

It's because the text variable has a second alpha value, which isn't supported everywhere. Maybe it should, but in the meantime $foreground will give you the text color with no alpha.

Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

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

No branches or pull requests

3 participants