Skip to content

Alignment breaking auto size container #5359

@willmcgugan

Description

@willmcgugan

When alignment is applied to an auto-sizing container, it adjusts the size in strange ways.

If parent and child are the same size, as should be the case in this code, then alignment shouldn't have any effect.

from textual.app import App, ComposeResult
from textual import containers
from textual.widgets import Button


class Sidebar(containers.Vertical):
    DEFAULT_CSS = """
    Sidebar {       
        width: auto;
        height: auto;
        background: blue;
        align-vertical: middle;

        #contents {
            width: auto;
            height: auto;
            background: red;
            border: white;
        }        
    }
    """

    def compose(self) -> ComposeResult:
        with containers.Vertical(id="contents"):
            yield Button("Start")
            yield Button("Stop")


class FloatSidebarApp(App):
    def compose(self) -> ComposeResult:
        yield Sidebar()


FloatSidebarApp().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