简体   繁体   中英

How to write more than 1 line of text delimited by \n using show_alert()?

I have recently found that there is a possibility to display sweet alerts in shiny using the package shinyWidgets .

I am trying to put more than 1 line of text delimited by \n in the function show_alert() but I cannot find any way to get this.

This is what I have:

在此处输入图像描述

This is what I want (ignore the different format of the letters or the indentation, I am not interested in having two lines with different format).

在此处输入图像描述

Attempts:

  1. text = paste("This data is....", "Please, be careful with...", sep="\n")
  2. text = paste("This data is....", "\n", "Please, be careful with...")
  3. text = paste0("This data is....", "\n", "Please, be careful with...")
  4. text = "This data is....\nPlease, be careful with..."

Code:

library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  tags$h2("Sweet Alert examples"),
  actionButton(
    inputId = "success",
    label = "Submit type of data",
    icon = icon("check")
  )
)

server <- function(input, output, session) {
  
  observeEvent(input$success, {
    show_alert(
      title = "Are you sure?",
      text = "This data is....\nPlease, be careful with...",
      type = "warning"
    )
  })

}

if (interactive())
  shinyApp(ui, server)

Does anybody know how to help me?

Thanks in advance

We can use show_alert 's html parameter:

library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  tags$h2("Sweet Alert examples"),
  actionButton(
    inputId = "success",
    label = "Submit type of data",
    icon = icon("check")
  )
)

server <- function(input, output, session) {
  
  observeEvent(input$success, {
    show_alert(
      title = "Are you sure?",
      text = HTML("This data is....<br>Please, be careful with..."),
      type = "warning",
      html = TRUE
    )
  })
  
}

if (interactive())
  shinyApp(ui, server)

结果

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM