render.ui

render.ui(self, _fn=None)

Reactively render HTML content.

Note: If you want to write your function with Shiny Express syntax, where the UI components are automatically captured as the code is evaluated, use express instead of this function.

This function is used to render HTML content, but it requires that the funciton returns the content, using Shiny Core syntax.

Returns

Type Description
A decorator for a function that returns an object of type TagChild.

Tips

The name of the decorated function (or @output(id=...)) should match the id of a output_ui container (see output_ui 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, reactive, render, ui

app_ui = ui.page_fluid(
    ui.input_action_button("add", "Add more controls"),
    ui.output_ui("moreControls"),
)


def server(input: Inputs, output: Outputs, session: Session):
    @render.ui
    @reactive.event(input.add)
    def moreControls():
        return ui.TagList(
            ui.input_slider("n", "N", min=1, max=1000, value=500),
            ui.input_text("label", "Label"),
        )


app = App(app_ui, server)