StaticText#

This component replaces a classic Panel component

pn.ui.StaticText supersedes pn.widgets.StaticText, which remains available and is documented in the classic StaticText reference.

import panel as pn
import panel.ui

pn.extension()

The StaticText widget displays a labeled text value that cannot be edited. It lines up with the other Material inputs, which makes it useful for read-only fields in forms and Param generated UIs.

Discover more about interactive widgets in the Panel interactivity guides, or learn about callbacks and links and declarative UIs with Param.

Parameters#

For customization options, see the Panel Material UI customization guides.

Core#

  • disabled (bool): Whether the text is rendered in the disabled color.

  • value (object): The value to display. Strings are rendered as HTML, any other value is converted to a string and escaped.

Display#

  • description (str): A description shown as a tooltip next to the label.

  • label (str): The label displayed above the value.

Styling#

  • sx (dict): Component level styling API.

  • theme_config (dict): Theming API.

Aliases#

For compatibility with Panel certain parameters are allowed as aliases:

  • name: Alias for label


Basic Usage#

Display a value with a label:

static_text = pn.ui.StaticText(label='Model', value='gpt-4o-mini')
static_text

Updating the value updates the displayed text:

static_text.value = 'claude-sonnet'

HTML and Other Values#

String values may contain HTML markup, while other values are escaped before they are displayed:

pn.ui.Column(
    pn.ui.StaticText(label='Status', value='<b>Running</b> since 10:15'),
    pn.ui.StaticText(label='Retries', value=3),
    pn.ui.StaticText(label='Raw markup', value=['<b>escaped</b>']),
)

Read-Only Parameters#

Map a parameter to StaticText to display it read-only in a Param generated UI:

import param

class Run(param.Parameterized):

    run_id = param.String(default='a1b2c3', constant=True)

    epochs = param.Integer(default=10, bounds=(1, 100))

pn.ui.Paper(pn.Param(Run(), widgets={'run_id': pn.ui.StaticText}))

API Reference#

Show all parameters and their current values:

pn.ui.StaticText(label='StaticText', value='Some text').api(jslink=True)

References#

Panel Documentation:

Material UI: