{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "import panel as pn\nimport panel_material_ui as pmui\n\npn.extension()"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "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.\n\nDiscover more about interactive widgets in the [Panel interactivity guides](https://panel.holoviz.org/how_to/interactivity/index.html), or learn about [callbacks and links](https://panel.holoviz.org/how_to/links/index.html) and [declarative UIs with Param](https://panel.holoviz.org/how_to/param/index.html)."
},
{
"cell_type": "markdown",
"metadata": {},
"source": "#### Parameters\n\nFor customization options, see the [Panel Material UI customization guides](https://panel-material-ui.holoviz.org/customization/index.html).\n\n##### Core\n\n* **`disabled`** (`bool`): Whether the text is rendered in the disabled color.\n* **`value`** (`object`): The value to display. Strings are rendered as HTML, any other value is converted to a string and escaped.\n\n##### Display\n\n* **`description`** (`str`): A description shown as a tooltip next to the label.\n* **`label`** (`str`): The label displayed above the value.\n\n##### Styling\n\n- **`sx`** (dict): Component level styling API.\n- **`theme_config`** (dict): Theming API.\n\n##### Aliases\n\nFor compatibility with Panel certain parameters are allowed as aliases:\n\n- **`name`**: Alias for `label`\n\n___"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "### Basic Usage\n\nDisplay a value with a label:"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "static_text = pmui.StaticText(label='Model', value='gpt-4o-mini')\nstatic_text"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Updating the `value` updates the displayed text:"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "static_text.value = 'claude-sonnet'"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "### HTML and Other Values\n\nString values may contain HTML markup, while other values are escaped before they are displayed:"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "pmui.Column(\n pmui.StaticText(label='Status', value='Running since 10:15'),\n pmui.StaticText(label='Retries', value=3),\n pmui.StaticText(label='Raw markup', value=['escaped']),\n)"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "### Read-Only Parameters\n\nMap a parameter to `StaticText` to display it read-only in a Param generated UI:"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "import param\n\nclass Run(param.Parameterized):\n\n run_id = param.String(default='a1b2c3', constant=True)\n\n epochs = param.Integer(default=10, bounds=(1, 100))\n\npmui.Paper(pn.Param(Run(), widgets={'run_id': pmui.StaticText}))"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "## API Reference\n\nShow all parameters and their current values:"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "pmui.StaticText(label='StaticText', value='Some text').api(jslink=True)"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "### References\n\n**Panel Documentation:**\n\n- [Panel StaticText Reference](https://panel.holoviz.org/reference/widgets/StaticText.html)\n- [Declarative UIs with Param](https://panel.holoviz.org/how_to/param/index.html)\n\n**Material UI:**\n\n- [Material UI Typography Reference](https://mui.com/material-ui/react-typography/)"
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}