www
的文件夹中。更多信息请参见此处:https://shiny.rstudio.com/articles/css.html。我在我的示例中做到了这一点。
如果你右键点击箭头并选择 检查元素,你会找到你要找的样式名称。在那里你可以测试不同的颜色。
.value-box .icon i
。在图片的右上角你可以看到图标的类型。然后你就可以将这个样式和你选择的颜色添加到新创建的 .css 中:/*arrow down*/
.value-box .icon i.fa.fa-angle-down{
color: rgb(255, 0, 0); /*red*/
}
/*arrow up*/
.value-box .icon i.fa.fa-angle-up{
color: rgb(0, 153, 0); /*green*/
}
---
title: "Untitled"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
css: www/styles.css
---
以下是结果:
#arrow down
library(flexdashboard)
rule = -3
valueBox(rule,
"Title + subtitle",
icon = ifelse(rule >= 0, "fa-angle-up", "fa-angle-down"),
color = "white")
向上箭头:
library(flexdashboard)
rule = 3
valueBox(rule,
"Title + subtitle",
icon = ifelse(rule >= 0, "fa-angle-up", "fa-angle-down"),
color = "white")
library(shinydashboard)
library(shiny)
rule <- -100
up <- tags$i(
class = "fa fa-angle-up",
style = "color: green"
)
down <- tags$i(
class = "fa fa-angle-down",
style = "color: red"
)
ui <- dashboardPage(
dashboardHeader(title = "Value boxes"),
dashboardSidebar(),
dashboardBody(
fluidRow(
# A static valueBox
valueBox(rule,
"Title + subtitle",
icon = if(rule > 0) up else down,
color = 'black')
),
)
)
server <- function(input, output) {
}
shinyApp(ui, server)
带有正数值的:
rule <- 100