Skip to content

Custom widgets not rendered in TabbedContent #6204

@CleverLemming1337

Description

@CleverLemming1337

Hello! I just started building an app with Textual and encountered an issue. I'm using my custom widgets within TabbedContent, but they are not displayed.
If I wrap them in a Container, it's working.

Here's my code:

class CustomWidget(Widget):
    def compose(self) -> ComposeResult:
        yield Label("My custom widget")

class DemoApp(App):
    def compose(self) -> ComposeResult:
        yield Header()
        with TabbedContent():
            with TabPane("Start", id="start"):
                yield Label("Welcome")
                yield CustomWidget()
        yield Footer()

Result:

Image

When I wrap the CustomWidget in a container:

class CustomWidget(Widget):
    def compose(self) -> ComposeResult:
        yield Label("My custom widget")

class DemoApp(App):
    def compose(self) -> ComposeResult:
        yield Header()
        with TabbedContent():
            with TabPane("Start", id="start"):
                yield Label("Welcome")
                with Container():
                    yield CustomWidget()
        yield Footer()

Result:

Image

Additionally, if I put two widgets inside the same container, only the first one is rendered.

Does anyone have an idea how to fix this?

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