text
Displays a value as a static text.
Note that in order to create a text
control, you don't need to specify the control name
in the text template. See the documentation for Controls for more details.
Properties¶
Name | Type | Default | Description |
---|---|---|---|
(★) |
any dynamic |
"" | The value displayed as text by this control. |
raw |
bool |
False | If set to True, the component renders as an HTML <span> element without any default style. |
mode |
str |
Define the way the text is processed:
|
|
format |
str |
The format to apply to the value. |
|
id |
str |
The identifier that will be assigned to the rendered HTML component. |
|
properties |
dict[str, any] |
Bound to a dictionary that contains additional properties for this element. |
|
class_name |
str dynamic |
The list of CSS class names that will be associated with the generated HTML Element. |
|
hover_text |
str dynamic |
The information that is displayed when the user hovers over this element. |
(★)value
is the default property for this visual element.
Details¶
The format property uses a format string like the ones used by the string format() function of Python.
If the value is a date
or a datetime
, then format can be set to a date/time
formatting string.
Styling¶
All the text controls are generated with the "taipy-text" CSS class. You can use this class name to select the text controls on your page and apply style.
Usage¶
Display value¶
You can represent a variable value as a simple, static text:
Definition
<|{value}|>
<taipy:text>{value}</taipy:text>
import taipy.gui.builder as tgb
...
tgb.text("{value}")
Formatted output¶
If your value is a floating point value, you can use the format property to indicate what the output format should be used.
To display a floating point value with two decimal places:
Definition
<|{value}|text|format=%.2f|>
<taipy:text format="%.2f">{value}</taipy:text>
import taipy.gui.builder as tgb
...
tgb.text("{value}", format="%.2f")