render.text
self, _fn=None, *, inline=False) render.text(
Reactively render text.
When used in Shiny Express applications, this defaults to displaying the text as normal text on the web page. When used in Shiny Core applications, this should be paired with output_text
in the UI.
Parameters
inline : bool = False
-
(Express only). If
True
, the result is displayed inline. (This argument is passed tooutput_text
.)
Returns
:
-
A decorator for a function that returns a string.
Tip
The name of the decorated function (or @output(id=...)
) should match the id
of a output_text
container (see output_text
for example usage).
See Also
Examples
#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
## file: app.py
from shiny import App, Inputs, Outputs, Session, render, ui
app_ui = ui.page_fluid(
ui.input_text("txt", "Enter the text to display below:", "delete me"),
ui.row(
ui.column(6, ui.code("ui.output_text()"), ui.output_text("text")),
ui.column(
6,
ui.code("ui.output_text_verbatim(placeholder=True)"),
ui.output_text_verbatim("verb", placeholder=True),
),
),
ui.row(
ui.column(6),
ui.column(
6,
ui.code("ui.output_text_verbatim(placeholder=False)"),
ui.output_text_verbatim("verb_no_placeholder", placeholder=False),
),
),
)
def server(input: Inputs, output: Outputs, session: Session):
@render.text
def text():
return input.txt()
@render.text
def verb():
return input.txt()
@render.text
def verb_no_placeholder():
return input.txt()
app = App(app_ui, server)