express.ui.remove_ui(selector, multiple=False, immediate=False, session=None)

Remove UI objects.


selector: str

A string that is accepted by jQuery’s selector (i.e. the string x to be placed in a $(x) jQuery call), which determines the element(s) to remove. If you want to remove a Shiny input or output, note that many of these are wrapped in <div>s, so you may need to use a somewhat complex selector — see the Examples below. (Alternatively, you could also wrap the inputs/outputs that you want to be able to remove easily in a <div> with an id.)

multiple: bool = False

In case your selector matches more than one element, multiple determines whether Shiny should insert the UI object relative to all matched elements or just relative to the first matched element (default).

immediate: bool = False

Whether the UI object should be immediately inserted or removed, or whether Shiny should wait until all outputs have been updated and all effects have been run (default).

session: Optional[Session] = None

A Session instance. If not provided, it is inferred via get_current_session.

See Also


#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400

## file:
from shiny import reactive
from import input, ui

ui.input_action_button("rmv", "Remove UI")
ui.input_text("txt", "Click button above to remove me")

def _():
    ui.remove_ui(selector="div:has(> #txt)")