Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

65
Vistas
Dynamically change Shinydashboard css style elements

I need to whitelabel a shiny dashboard build within the shinydashboard package framework. For this I need to change the following tag code in my dashboard body dynamically:

tags$head(tags$style(HTML('
        /* logo */
        .skin-blue .main-header .logo {
                              background-color: #545454;
                              }')))

js <-"Shiny.addCustomMessageHandler('change_logo', function(logo_W) {
  /* logo */
    .skin-blue .main-header .logo {
      background-color: logo_W;
    }
});"

ui <- function() {
    dashboardPage(dashboardHeader(),
                  dashboardSidebar(),
                  dashboardBody(
                      tags$head(tags$style(HTML(js))),
                  ),
                  skin = "blue")
}

server <- function(input, output, session) {
start <- reactiveVal(1)
    observeEvent(start() == 1 , {
        session$sendCustomMessage("change_logo", "#545454")
    })
}

shinyApp(ui, server)

I tried to solve the problem in a few ways. One option was to put everything in a UIoutput, but this

doesn't work with shinydashboard, the css doesn't register and it messes up the initiation process.

I tried opening the shinyapp within another app to do a call in the starting app to the server for

the colorcoding, too bad that doesn't work either.

My plan is to do it with java then and I got this code so far for one the logo part of the style

tag. It doesn't work either, but saw an example of this where someone changed the skin color with

similar code, so it should be possible.

The help is much appreciated

7 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos