[go: up one dir, main page]

Skip to content

Border-title-background

The border-title-background style sets the background color of the border_title.

Syntax

border-title-background: (<color> | auto) [<percentage>];

Example

The following examples demonstrates customization of the border color and text style rules.

BorderTitleApp  Textual Rocks ━━━━━━━━━━━━━ Hello, World! ━━━━━━━━━━━━━ Textual Rocks 

from textual.app import App, ComposeResult
from textual.widgets import Label


class BorderTitleApp(App):
    CSS_PATH = "border_title_colors.tcss"

    def compose(self) -> ComposeResult:
        yield Label("Hello, World!")

    def on_mount(self) -> None:
        label = self.query_one(Label)
        label.border_title = "Textual Rocks"
        label.border_subtitle = "Textual Rocks"


if __name__ == "__main__":
    app = BorderTitleApp()
    app.run()
Screen {
    align: center middle;
}

Label {
    padding: 4 8;
    border: heavy red;

    border-title-color: green;
    border-title-background: white;
    border-title-style: bold;

    border-subtitle-color: magenta;
    border-subtitle-background: yellow;
    border-subtitle-style: italic;
}

CSS

border-title-background: blue;

Python

widget.styles.border_title_background = "blue"

See also