首页 > 解决方案 > 如何在 Shiny 中的文本旁边插入信息图标?

问题描述

如何在右侧插入一个绿色信息图标,上面写着“选择最佳数量的垃圾箱”。你能帮助我吗?

我真的很感激帮助!

我在下面插入一个可执行代码:

library(shiny)
library(shinythemes)

ui <- fluidPage(
                        
                        
                        titlePanel("Old Faithful Geyser Data"),
                        
                        
                        sidebarLayout(
                            sidebarPanel(h4("Select the best the number of bins"),
                                         br(),
                                         br(),
                                sliderInput("bins",
                                            "Number of bins:",
                                            min = 1,
                                            max = 50,
                                            value = 30)
                            ),
                            
                            
                            mainPanel(
                                plotOutput("distPlot")
                            )
                        )
)


server <- function(input, output) {
    
    output$distPlot <- renderPlot({
        
        x    <- faithful[, 2]
        bins <- seq(min(x), max(x), length.out = input$bins + 1)
        
        
        hist(x, breaks = bins, col = 'darkgray', border = 'white')
    })
}


shinyApp(ui = ui, server = server)

标签: rshiny

解决方案


只需iconh4. 要更改颜色,您可以使用style = "color: green".

library(shiny)

ui <- fluidPage(
  titlePanel("Old Faithful Geyser Data"),
  sidebarLayout(
      sidebarPanel(h4("Select the best the number of bins", 
                      icon("info", style = "color: green")),
                   br(),
                   br(),
          sliderInput("bins",
                      "Number of bins:",
                      min = 1,
                      max = 50,
                      value = 30)
      ),
      mainPanel(
          plotOutput("distPlot")
      )
  )
)

server <- function(input, output) {
    output$distPlot <- renderPlot({
        x    <- faithful[, 2]
        bins <- seq(min(x), max(x), length.out = input$bins + 1)
        hist(x, breaks = bins, col = 'darkgray', border = 'white')
    })
}

shinyApp(ui = ui, server = server)

推荐阅读