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


textual.widgets.Static class

def __init__(
    self,
    renderable="",
    *,
    expand=False,
    shrink=False,
    markup=True,
    name=None,
    id=None,
    classes=None,
    disabled=False
):

Bases: Widget

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

Parameters
Parameter Default Description
renderable
RenderableType
''

A Rich renderable, or string containing console markup.

expand
bool
False

Expand content if required to fill container.

shrink
bool
False

Shrink content if required to fill container.

markup
bool
True

True if markup should be parsed and rendered.

name
str | None
None

Name of widget.

id
str | None
None

ID of Widget.

classes
str | None
None

Space separated list of class names.

disabled
bool
False

Whether the static is disabled or not.

update method

def update(self, renderable=''):

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

Parameters
Parameter Default Description
renderable
RenderableType
''

A new rich renderable. Defaults to empty renderable;