rstudio / shinydashboard

Shiny Dashboarding framework
https://rstudio.github.io/shinydashboard/
Other
896 stars 298 forks source link

How to change the title color in shinydashboard from server using shinyjs #368

Open yikeshu0611 opened 3 years ago

yikeshu0611 commented 3 years ago

Great thanks for you. The shiny dashboard is so greate. I want to change the title color of the titlex It not works bellow

library(shinydashboard)
library(shiny)
library(shinyjs)
header <- dashboardHeader(title='want to be red') |> 
  tagAppendAttributes(id='nn',.cssSelector = 'span')

side <- dashboardSidebar(
)

body <- dashboardBody(
  useShinyjs()
)

ui <- dashboardPage(header,side,body,title = 'nhanesR')

server <- function(input, output, session){
  runjs('$("#nn > span").css("color", "red")')
}
shinyApp(ui,server)
ismirsehregal commented 2 years ago

No need for shinyjs

library(shinydashboard)
library(shiny)

ui <- dashboardPage(dashboardHeader(title = div('want to be red', style = "color: red;")),
                dashboardSidebar(),
                dashboardBody(),
                title = 'nhanesR')

server <- function(input, output, session) {}

shinyApp(ui, server)