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

Alignment breaking auto size container #5359

Closed
willmcgugan opened this issue Dec 8, 2024 · 1 comment · Fixed by #5360
Closed

Alignment breaking auto size container #5359

willmcgugan opened this issue Dec 8, 2024 · 1 comment · Fixed by #5360

Comments

@willmcgugan
Copy link
Collaborator

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()
Copy link

github-actions bot commented Dec 8, 2024

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

Successfully merging a pull request may close this issue.

1 participant