- shiny.ui.remove_ui(selector, multiple=False, immediate=False, session=None)#
Remove UI objects
str) – A string that is accepted by jQuery’s selector (i.e. the string
xto 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.)
bool) – 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).
bool) – 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).
#| standalone: true #| components: [editor, viewer] #| layout: vertical #| viewerHeight: 400 from shiny import * 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)
- Return type