Skip to content

Static

A widget which displays static content. Can be used for Rich renderables and can also be the base for other types of widgets.

  • Focusable
  • Container

Example

The example below shows how you can use a Static widget as a simple text label (but see Label as a way of displaying text).

StaticApp Hello, world!

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


class StaticApp(App):
    def compose(self) -> ComposeResult:
        yield Static("Hello, world!")


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

Reactive Attributes

This widget has no reactive attributes.

Messages

This widget posts no messages.

Bindings

This widget has no bindings.

Component Classes

This widget has no component classes.

See Also


Bases: Widget

A widget to display simple static content, or use as a base class for more complex widgets.

Parameters:

Name Type Description Default

renderable

RenderableType

A Rich renderable, or string containing console markup.

''

expand

bool

Expand content if required to fill container.

False

shrink

bool

Shrink content if required to fill container.

False

markup

bool

True if markup should be parsed and rendered.

True

name

str | None

Name of widget.

None

id

str | None

ID of Widget.

None

classes

str | None

Space separated list of class names.

None

disabled

bool

Whether the static is disabled or not.

False

update

update(renderable='')

Update the widget's content area with new text or Rich renderable.

Parameters:

Name Type Description Default

renderable

RenderableType

A new rich renderable. Defaults to empty renderable;

''