Skip to content

Tabs widget does not support Rich #5635

Closed
@charles-001

Description

@charles-001

Rich theme (and Rich in general) is not being supported with Tabs widget using v2.0.0. Also, emojis are not working anymore.

I tried to use from_markup, but it isn't working:

def on_mount(self) -> None:
        self.query_one(Tabs).add_tab(Text.from_markup("[special_red]Special Red Again"))

Error:
AttributeError: 'Text' object has no attribute 'translate'

MRE:

from rich.text import Text
from rich.theme import Theme as RichTheme
from textual.app import App, ComposeResult
from textual.widgets import Tabs

NAMES = [
    "[special_red]Special Red",
    "[red]Red",
    "[yellow]Yellow",
    ":skull: Skull",
]


class MREApp(App):

    def __init__(self):
        super().__init__()

        theme = RichTheme(
            {
                "special_red": "#ff5e5e",
            }
        )
        self.console.push_theme(theme)

    def compose(self) -> ComposeResult:
        yield Tabs(*NAMES)


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

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