在闪亮的应用程序中更改tabPanels名称的字体

时间:2019-10-17 18:16:41

标签: r shiny

下面有一个闪亮的应用程序,其中有一个基于selectInput()的标签面板。有没有办法更改tabPanels名称的字体和字体颜色?

library(shiny)

# Define UI for random distribution app ----
ui <- fluidPage(

  # App title ----
  titlePanel("Tabsets"),

  # Sidebar layout with input and output definitions ----
  sidebarLayout(

    # Sidebar panel for inputs ----
    sidebarPanel(
      selectInput("sec","Page",choices=c("Introduction","Explore Funds"),selected = "Introduction"),





    ),

    # Main panel for displaying outputs ----
    mainPanel(
      uiOutput("tabers"),



    )
  )
)

# Define server logic for random distribution app ----
server <- function(input, output) {
  output$tabers<-renderUI({
    if(input$sec=="Introduction"){
      tabsetPanel(id="I",type="tabs",tabPanel("Introduction", id = "StartHR"))
    }
    else{
      tabsetPanel(id="I2",type="tabs",tabPanel("Explore Funds", id = "StartHR2"))

    }
                                              })


}

# Create Shiny app ----
shinyApp(ui, server)

1 个答案:

答案 0 :(得分:1)

使用此CSS:

.nav-tabs>li>a {
  font-family: "Lucida Sans", sans-serif;
  color: red;
}

您必须将其放在tags$style中:

css <- '.nav-tabs>li>a {
  font-family: "Lucida Sans", sans-serif;
  color: red;
}'

ui <- fluidPage(
  tags$head(tags$style(HTML(css))),
  ......