My goal is to change the color of an actionButton
in Shine sidebar. In my dashboard content is organized using navbarPage
.
I found different solutions, for example:
These both work great, but as soon as I add a navbar to the dashboard they stop working. The only thing changing color seems to be the border of the button instead of the whole background.
Below a reproducible example.
This works
library(shiny)
shinyApp(
ui = fluidPage(
titlePanel("Styling Action Button"),
sidebarLayout(
sidebarPanel(
h4("Default CSS styling"),
# default styling
actionButton('downloadData1', label= 'Download 1'),
tags$hr(),
actionButton("download1", label="Download with style", class = "butt1"),
# style font family as well in addition to background and font color
tags$head(tags$style(".butt1{background-color:orange;} .butt1{color: black;} .butt1{font-family: Courier New}"))
),
mainPanel()
)
),
server = function(input, output){}
)
This doesn't work
library(shiny)
shinyApp(
ui = fluidPage(
navbarPage("Test multi page",
tabPanel("test",
titlePanel("Styling Action Button"),
sidebarLayout(
sidebarPanel(
h4("Default CSS styling"),
# default styling
actionButton('downloadData1', label= 'Download 1'),
tags$hr(),
actionButton("download1", label="Download with style", class = "butt1"),
# style font family as well in addition to background and font color
tags$head(tags$style(".butt1{background-color:orange;} .butt1{color: black;} .butt1{font-family: Courier New}"))
),
mainPanel()
)
))),
server = function(input, output){}
)
This doesn't work either
library(shiny)
shinyApp(
ui = fluidPage(
navbarPage("Test multi page", theme = shinytheme("cerulean"),
tabPanel("test",
titlePanel("Styling Download Button"),
sidebarLayout(
sidebarPanel(
h4("Default CSS styling"),
# default styling
actionButton('downloadData1', label= 'Download 1'),
actionButton("download1", label="Download with style",
style="color: #fff; background-color: #337ab7")
),
mainPanel()
)
))),
server = function(input, output){})