Skip to content

Instantly share code, notes, and snippets.

@adisarid
Created December 4, 2020 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adisarid/e5849d5fc890d10f32a5cf074e978da7 to your computer and use it in GitHub Desktop.
Save adisarid/e5849d5fc890d10f32a5cf074e978da7 to your computer and use it in GitHub Desktop.
Example for making a modal with box elements and a selectInput
library(shiny)
library(shinydashboard)
# Define UI for application that draws a histogram
ui <- dashboardPage(title = "Simple dashboard",
header = dashboardHeader(),
sidebar = dashboardSidebar(),
dashboardBody(actionButton("open_modal", "Open modal"),
textOutput("chosen_fruit"))
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$chosen_fruit <- renderText({
req(input$some_input)
paste0("You have chosen: ", input$some_input)
})
observeEvent(input$open_modal,
showModal(
modalDialog(
tagList(box(title = "First box", status = "primary", width = 12,
selectInput("some_input",
"Select here",
choices = c("Orange", "Apple", "Paer"))),
box(title = "Be sure!", status = "warning", solidHeader = T, width = 12,
"Choosing fruits is not an easy task. Be sure of your selection!"
)),
title = "A simple modal", size = "l", easyClose = F)
)
)
}
# Run the application
shinyApp(ui = ui, server = server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment