Kaverisonu
Kaverisonu

Reputation: 101

How can I add a message box in R Shiny?

I am trying to display messages like "user is authenticated" or "account created" in Shiny with uiOutput, but it overrides the front page of my Shiny dashboard which is not required.

Is there a function in Shiny in which we can add a message box like thing, which can be closed once the message is displayed and then the user can proceed?

Upvotes: 8

Views: 10371

Answers (1)

Florian
Florian

Reputation: 25385

You could use modalDialogs for that, here is a working example:

library(shiny)
ui = fluidPage(
  actionButton("login", "Log in"),
  textInput('userid','User id:',value=' definitely not Florian')
)
server = function(input, output) {
  observeEvent(input$login, {
    showModal(modalDialog(
      title = "You have logged in.",
      paste0("It seems you have logged in as",input$userid,'.'),
      easyClose = TRUE,
      footer = NULL
    ))
  })
}

shinyApp(ui,server)

Hope this helps!

Upvotes: 15

Related Questions