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:
text = paste("This data is....", "Please, be careful with...", sep="\n")
text = paste("This data is....", "\n", "Please, be careful with...")
text = paste0("This data is....", "\n", "Please, be careful with...")
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
CodePudding user response:
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)