Created
December 4, 2020 07:57
-
-
Save adisarid/e5849d5fc890d10f32a5cf074e978da7 to your computer and use it in GitHub Desktop.
Example for making a modal with box elements and a selectInput
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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