Skip to content

The title in the Header always seems to be off by one character #6103

@davep

Description

@davep

It seems that the title within a Header is always off by one character, in respect to being central in the display, when compared to another widget that shows the same text centred:

from textual.app import App, ComposeResult, RenderResult
from textual.containers import Horizontal
from textual.widgets import Header


class MiddleOfDisplay(Horizontal):

    DEFAULT_CSS = """
    MiddleOfDisplay {
        content-align: center middle;
        height: 1;
    }
    """

    def render(self) -> RenderResult:
        return "Title - Title"

class HeaderCheckApp(App[None]):

    TITLE = "Title"
    SUB_TITLE = "Title"

    def compose(self) -> ComposeResult:
        yield Header()
        yield MiddleOfDisplay()

if __name__ == "__main__":
    HeaderCheckApp().run()
Image

I suspect this has long been the case; I did a quick check of an assortment of Textual versions going back to 1.0.0 and the result is always the same.

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