Skip to content

Header

A simple header widget which docks itself to the top of the parent container.

Note

The application title which is shown in the header is taken from the title and sub_title of the application.

  • Focusable
  • Container

Example

The example below shows an app with a Header.

HeaderApp HeaderApp

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


class HeaderApp(App):
    def compose(self) -> ComposeResult:
        yield Header()


if __name__ == "__main__":
    app = HeaderApp()
    app.run()

This example shows how to set the text in the Header using App.title and App.sub_title:

HeaderApp Header Application — With title and sub-title

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


class HeaderApp(App):
    def compose(self) -> ComposeResult:
        yield Header()

    def on_mount(self) -> None:
        self.title = "Header Application"
        self.sub_title = "With title and sub-title"


if __name__ == "__main__":
    app = HeaderApp()
    app.run()

Reactive Attributes

Name Type Default Description
tall bool True Whether the Header widget is displayed as tall or not. The tall variant is 3 cells tall by default. The non-tall variant is a single cell tall. This can be toggled by clicking on the header.

Messages

This widget posts no messages.

Bindings

This widget has no bindings.

Component Classes

This widget has no component classes.


Bases: Widget

A header widget with icon and clock.

Parameters:

Name Type Description Default

show_clock

bool

True if the clock should be shown on the right of the header.

False

name

str | None

The name of the header widget.

None

id

str | None

The ID of the header widget in the DOM.

None

classes

str | None

The CSS classes of the header widget.

None

icon

str | None

Single character to use as an icon, or None for default.

None

time_format

str | None

Time format (used by strftime) for clock, or None for default.

None

icon class-attribute instance-attribute

icon = Reactive('⭘')

A character for the icon at the top left.

screen_sub_title property

screen_sub_title

The sub-title that this header will display.

This depends on Screen.sub_title and App.sub_title.

screen_title property

screen_title

The title that this header will display.

This depends on Screen.title and App.title.

tall class-attribute instance-attribute

tall = Reactive(False)

Set to True for a taller header or False for a single line header.

time_format class-attribute instance-attribute

time_format = Reactive('%X')

Time format of the clock.