How to change color in shiny dashboard?
Based on the example you posted a link to you can try:
ui.R
dashboardPage(
dashboardHeader(
title = "Example of a long title that needs more space",
titleWidth = 450
),
dashboardSidebar( sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Widgets", icon = icon("th"), tabName = "widgets",
badgeLabel = "new", badgeColor = "green")
)),
dashboardBody(
# Also add some custom CSS to make the title background area the same
# color as the rest of the header.
tags$head(tags$style(HTML('
/* logo */
.skin-blue .main-header .logo {
background-color: #f4b943;
}
/* logo when hovered */
.skin-blue .main-header .logo:hover {
background-color: #f4b943;
}
/* navbar (rest of the header) */
.skin-blue .main-header .navbar {
background-color: #f4b943;
}
/* main sidebar */
.skin-blue .main-sidebar {
background-color: #f4b943;
}
/* active selected tab in the sidebarmenu */
.skin-blue .main-sidebar .sidebar .sidebar-menu .active a{
background-color: #ff0000;
}
/* other links in the sidebarmenu */
.skin-blue .main-sidebar .sidebar .sidebar-menu a{
background-color: #00ff00;
color: #000000;
}
/* other links in the sidebarmenu when hovered */
.skin-blue .main-sidebar .sidebar .sidebar-menu a:hover{
background-color: #ff69b4;
}
/* toggle button when hovered */
.skin-blue .main-header .navbar .sidebar-toggle:hover{
background-color: #ff69b4;
}
')))
)
)
I commented the CSS to point out what it modifies.
How to change the background color of the Shiny Dashboard Body
Ok, ideally I would like you to use dashboardthemes
package https://github.com/nik01010/dashboardthemes, where you can create your own themes with ease, however you can css the .content-wrapper
like so:
#rm(list = ls())
library(shinydashboard)
library(shiny)
library(DT)
library(shinyWidgets)
library(dplyr)
ui=shinyUI(
dashboardPage(
dashboardHeader(
title = "Example of a long title that needs more space",
titleWidth = 450
),
dashboardSidebar( sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Widgets", icon = icon("th"), tabName = "widgets",
badgeLabel = "new", badgeColor = "green")
)),
dashboardBody(
tags$head(tags$style(HTML('
/* logo */
.skin-blue .main-header .logo {
background-color: #f4b943;
}
/* logo when hovered */
.skin-blue .main-header .logo:hover {
background-color: #f4b943;
}
/* navbar (rest of the header) */
.skin-blue .main-header .navbar {
background-color: #f4b943;
}
/* main sidebar */
.skin-blue .main-sidebar {
background-color: #f4b943;
}
/* active selected tab in the sidebarmenu */
.skin-blue .main-sidebar .sidebar .sidebar-menu .active a{
background-color: #ff0000;
}
/* other links in the sidebarmenu */
.skin-blue .main-sidebar .sidebar .sidebar-menu a{
background-color: #00ff00;
color: #000000;
}
/* other links in the sidebarmenu when hovered */
.skin-blue .main-sidebar .sidebar .sidebar-menu a:hover{
background-color: #ff69b4;
}
/* toggle button when hovered */
.skin-blue .main-header .navbar .sidebar-toggle:hover{
background-color: #ff69b4;
}
/* body */
.content-wrapper, .right-side {
background-color: #7da2d1;
}
')))
)
)
)
server=shinyServer(function(input,output,session){})
shinyApp(ui,server)
How to change background color and text color of a titlePanel in R Shiny?
titlePanel("This is my title")
tags$style(HTML("
body {
background-color: Black;
color: white;
}"))
You can use titlePanel to set your title in shiny instead of wrapping in HTML, and then for the CSS, it needs to be completely wrapped by HTML() and Quotes for it to work.
R Shiny: How do you change the background color of the Header?
Try something like
tags$style(".span12 {background-color: black;}")
instead of
tags$style("body {background-color: black;}")
Change the title header color permanently in shiny dashboard
You can create a custom theme to use with {shinydashboard} with the {fresh} package, more documentation here : https://dreamrs.github.io/fresh/articles/vars-shinydashboard.html
Here an example to modify header background color:
library(fresh)
# Create the theme
mytheme <- create_theme(
adminlte_color(
light_blue = "#E7FF6E"
)
)
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
header = dashboardHeader(title = "My dashboard"),
sidebar = dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Settings", tabName = "settings", icon = icon("sliders"))
)
),
body = dashboardBody(
use_theme(mytheme) # <-- use the theme
)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
how to change background and text color of DT Datable header in R Shiny
If the column names text is 'white' and background 'red'
server <- function(input, output) {
data <- tibble(name = c("Justin", "Corey", "Sibley"),
grade = c(50, 100, 100))
output$table <- DT::renderDT({
datatable(data, options = list(
initComplete = JS(
"function(settings, json) {",
"$(this.api().table().header()).css({'background-color': 'red', 'color': 'white'});",
"}")
))
})
}
-output
How to customise background colors in shinydashoard
.skin-blue .main-header .logo {
background-color: black;
color: white;
border-bottom: 0 solid transparent;
}
.skin-blue .main-header .logo:hover {
background-color: black;
}
adding this to css file should change the header logo background color to black and text white.
Here is the link for css file see line (1-139) for blue skin-
shinydashboard_blue_skin
I think you have to play around little bit with color (search sidebar in the above css file and you will find where to change)
Related Topics
Terminating an Apply-Based Function Early (Similar to Break)
Using The Result of Summarise (Dplyr) to Mutate The Original Dataframe
Add Geom_Line to Link All The Geom_Point in Boxplot Conditioned on a Factor with Ggplot2
R: Check If Value from Dataframe Is Within Range Other Dataframe
Separate String After Last Underscore
Convert Utf8 Code Point Strings Like <U+0161> to Utf8
"Nas Introduced by Coercion" During Cluster Analysis in R
How to Get The Intersection Point of Two Vector
Get Country (And Continent) from Longitude and Latitude Point in R
How to Split a Dataframe Column by The First Instance of a Character in Its Values
Get Plot() Bounding Box Values
How to Create a Prop.Table() for a Three Dimension Table
How to Find The Indices Where There Are N Consecutive Zeroes in a Row
Split Character Vector into Sentences
How to Plot Grid Plots on a Same Page
Write a File Using 'saverds()' So That It Is Backwards Compatible with Old Versions of R