我想創(chuàng)建一個(gè)閃亮的模態(tài),看起來(lái)像一個(gè)可怕的警告。
以下是我目前掌握的情況:
library(shiny)
ui = basicPage(
actionButton("show", "Show modal dialog")
)
server = function(input, output) {
observeEvent(input$show, {
showModal(modalDialog(
title = icon("bomb"),
"This is an important message!"
))
})
}
shinyApp(ui, server)
產(chǎn)生了這個(gè)
我怎樣才能使圖標(biāo)更大,居中,并像橙色或紅色的警告色?我使用bslib進(jìn)行主題化,所以理想情況下,警告色應(yīng)該與主題相關(guān)聯(lián)。
這是基于FontAwesome,它允許大小,見(jiàn)https://fontawesome.com/docs/web/style/size.
演示:
shiny::icon("bomb")
shiny::icon("bomb", class="fa-2xl")
shiny::icon("bomb", class="fa-10x", style="color: Tomato;")
分別是:
至于居中,如果你不怕居中。h4 & gt元素,這是可行的:
library(shiny)
ui = basicPage(
tags$style(HTML("h4 { text-align: center; }")),
actionButton("show", "Show modal dialog")
)
server = function(input, output) {
observeEvent(input$show, {
showModal(modalDialog(
title = icon("bomb", class="fa-10x", style="color: Tomato;"),
"This is an important message!"
))
})
}
shinyApp(ui, server)
你可以使用甜蜜的提醒,但是你只有四種圖標(biāo)選擇。
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
actionButton(
inputId = "btn",
label = "Launch a warning sweet alert",
icon = icon("check")
)
)
server <- function(input, output, session) {
observeEvent(input$btn, {
show_alert(
title = "Important !!",
text = "Read this message...",
type = "warning"
)
})
}
shinyApp(ui, server)