Closed wwyws0000 closed 4 years ago
You can provide HTML directly instead of just plain text, so you can add colours or any style you want with HTML.
You can provide HTML directly instead of just plain text, so you can add colours or any style you want with HTML.
Thank you. Could you provide an example? I'm not experienced enough with using HTML directly in Shiny. I managed to get it to work in modalDialog but for some reason it's not working for shinyalert:
library(shiny)
library(shinyalert)
# Main app UI
ui <- fluidPage(
useShinyalert()
,actionButton('msg1','modalDialog')
,actionButton('msg2','Shinyalert')
)
# Main app server
server <- function(input, output, session) {
observeEvent(input$msg1,{
showModal(
modalDialog(
title = 'modalDialog message'
,div(p("This is a message using ",style = 'font-size:160%;display: inline')
,p("modalDialog",style = 'font-size:160%; color:red;display: inline'))
)
)
})
observeEvent(input$msg2,{
shinyalert(
title = 'shinyalert message'
,div(p("This is a message using ",style = 'font-size:160%;display: inline')
,p("shinyalert",style = 'font-size:160%; color:red;display: inline'))
,html = TRUE
)
})
}
shinyApp(ui, server)
here in the example the modalDialog message has the modified text size and color, while the shinyalert message shows:
That looks like it should work. Maybe wrap it in as.character()
to make sure you're passing a string.
Wrapping it in as.character()
did the trick, Thank you!
Hi, thank you for developing this package. Is there any way to do some styling with the text in the modal? For example, coloring/highlighting part of the text to make it stand out to the user?