<- fluidPage(
ui checkboxGroupInput(
"checks",
"Check boxes",
choices = month.name,
selected = month.name[1]
),actionButton("search", "Search"),
uiOutput("ui_stuff")
)
<- function(input, output, session) {
server <- reactiveValues(checks = c())
reactive_checkboxes
observeEvent(input$checks, {
print("change")
$checks <- input$checks
reactive_checkboxes
})
observeEvent(input$search, {
if (is.null(input$checks)) {
showModal(modalDialog(
title = "Invalid search conditions!",
div(p("You must select at least one theme to filter the data."),
p("Click dismiss and your previously selected set of themes will be re-selected.")
)))
updateCheckboxGroupInput(session,
"checks",
selected = reactive_checkboxes$checks)
}
})
$ui_stuff <- renderUI({
output"dummy element here"
})
}
shinyApp(ui, server)
This was an idea I had
Reuse
Citation
BibTeX citation:
@online{hadley2024,
author = {Hadley, Charlie},
title = {Null Checkboxes in {Shiny}},
date = {2024-09-20},
url = {https://visibledata.co.uk/posts/2024-02-27_empty-checkboxes},
langid = {en}
}
For attribution, please cite this work as:
Hadley, Charlie. 2024. “Null Checkboxes in Shiny.”
September 20, 2024. https://visibledata.co.uk/posts/2024-02-27_empty-checkboxes.