Skip to content

overlay style removes the neighboring margin #5670

@TomJGooding

Description

@TomJGooding

The overlay style (added in Textual v0.24.0) is still undocumented, so I'm not sure if this is a bug or I've misunderstood how the overlay should work.

Here's a minimal example. After typing in the input to show the overlay, the top margin of the button below will disappear:

from textual.app import App, ComposeResult
from textual.widgets import Button, Input, Static


class MyOverlay(Static):
    DEFAULT_CSS = """
    MyOverlay {
        display: none;
        overlay: screen;
        background: $error;
    }
    """


class ExampleApp(App):
    CSS = """
    Button {
        margin: 2;
    }
    """

    def compose(self) -> ComposeResult:
        yield Input(placeholder="Type to show the overlay...")
        yield MyOverlay("This overlay removes the margin?")
        yield Button("Submit", variant="success")

    def on_input_changed(self, event: Input.Changed) -> None:
        self.query_one(MyOverlay).display = bool(event.value)


if __name__ == "__main__":
    app = ExampleApp()
    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