ui.remove_ui
=False, immediate=False, session=None) ui.remove_ui(selector, multiple
Remove UI objects.
Parameters
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 viaget_current_session
.
See Also
Examples
#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
## file: app.py
from shiny import App, Inputs, Outputs, Session, reactive, ui
app_ui = ui.page_fluid(
ui.input_action_button("rmv", "Remove UI"),
ui.input_text("txt", "Click button above to remove me"),
)
def server(input: Inputs, output: Outputs, session: Session):
@reactive.effect
@reactive.event(input.rmv)
def _():
ui.remove_ui(selector="div:has(> #txt)")
app = App(app_ui, server)