Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert a new line in shiny's modalDialog

Tags:

r

popup

shiny

In my shiny app I would like to have a popup window with some text. To make the text more readable I would like to include some linebreaks, but so far I have failed. Any idea how would I do that? I am currently using modalDialog()

 ui = basicPage(
actionButton("show", "Show modal dialog")
),
server = function(input, output) {
observeEvent(input$show, {
  showModal(modalDialog(
    title = "My text",
    "This is the first line. 
     This should be the second."
  ))
})
}

I have tried: br(), \n and several variations of those. Nothing worked.

Help!!!

like image 935
Beveline Avatar asked Jun 08 '17 10:06

Beveline


1 Answers

You can wrap it in HTML() and then use <br>, similar to your attempt mentioned above. So you could use instead: HTML("This is the first line.<br> This should be the second.")

For the full app, see below:

ui = basicPage(
  actionButton("show", "Show modal dialog")
)
server = function(input, output) {
  observeEvent(input$show, {
    showModal(modalDialog(
      title = "My text",
      HTML("This is the first line.<br> 
      This should be the second.")
    ))
  })
}
shinyApp(ui, server)
like image 180
Tonio Liebrand Avatar answered Nov 14 '22 08:11

Tonio Liebrand