Skip to content

Add a collapsible container widget #2918

@rodrigogiraoserrao

Description

@rodrigogiraoserrao

(This issue is reserved for the EuroPython 2023 sprint. If you are not participating in the sprint, please refrain from working on this issue. Thanks!)

This issue concerns itself with adding a new container widget to Textual.
This new container widget should be a collapsible container that can be toggled to show or hide its contents.

The diagram below exemplifies this behaviour:

Untitled-2023-07-11-2122

For users building apps, this collapsible widget should be usable in a way that is similar to the TabbedContent widget; something along the lines of

class MyApp(App):
    def compose(self):
        with CollapsibleContainer("Some title or label here"):
            yield Label("My label")
            yield Input()
            with Horizontal():
                yield Button("Button 1")
                yield Button("Button 2")
                yield Button("Button 3")

The collapsible container should have a reactive attribute that represents the label for the collapsible section.

This container widget is likely going to end up as a compound widget.
There should be another reactive attribute to control the toggled state of the container.

Take a look at #2333 to see what files need to be changed when you implement a new widget.
Then, don't be like me and also do the final step shown in #2399 to add your new widget to the widget gallery.

Good luck and have fun!

(As a follow-up, see issue #2919.)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions