如何在闪亮的仪表板中更改颜色?
How to change color in shiny dashboard?
(来自 shiny google 组的 post)
有人可以指出我必须修改闪亮仪表板颜色的标签名称吗?
修改自http://rstudio.github.io/shinydashboard/appearance.html#long-titles
这会将我的仪表板的左上角更改为橙色
tags$head(tags$style(HTML('
.skin-blue .main-header .logo {
background-color: #f4b943;
}
.skin-blue .main-header .logo:hover {
background-color: #f4b943;
}
')))
我不清楚如何将 header 和边栏的其余部分更改为橙色,以及如何在 "SideBarMenu" 上的项目被选中/突出显示时更改颜色。
根据您发布的示例 link 您可以尝试:
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;
}
')))
)
)
我评论了 CSS 以指出它修改的内容。
感谢 post。我认为您应该添加 "toggle button when hovered" 以使其完整。示例代码如下:
/* toggle button when hovered */
.skin-blue .main-header .navbar .sidebar-toggle:hover{
background-color: #ff69b4;
}
谢谢@NicE 的回答。另外:如果有人想控制侧边栏菜单选择左边框的颜色重音,border-left
属性 有效:
/* active selected tab in the sidebarmenu */
.skin-blue .main-sidebar .sidebar .sidebar-menu .active a{
background-color: #2e6984;
border-left: 3px solid #254264;
}
/* other links in the sidebarmenu */
.skin-blue .main-sidebar .sidebar .sidebar-menu a{
background-color: #3E8CB0;
color: #FFFFFF;
}
/* other links in the sidebarmenu when hovered */
.skin-blue .main-sidebar .sidebar .sidebar-menu a:hover{
background-color: #2e6984;
border-left: 3px solid #254264;
}
也许这个包可以进一步帮助你:
https://github.com/dreamRs/fresh
它允许很好地设置自定义主题和颜色,而无需自己处理 CSS 定义 - 但可以创建它们以供重复使用。
可在此处找到更多信息(相当详尽的一本书,主题更多!):https://unleash-shiny.rinterface.com/beautify-with-fresh.html
(来自 shiny google 组的 post)
有人可以指出我必须修改闪亮仪表板颜色的标签名称吗?
修改自http://rstudio.github.io/shinydashboard/appearance.html#long-titles 这会将我的仪表板的左上角更改为橙色
tags$head(tags$style(HTML('
.skin-blue .main-header .logo {
background-color: #f4b943;
}
.skin-blue .main-header .logo:hover {
background-color: #f4b943;
}
')))
我不清楚如何将 header 和边栏的其余部分更改为橙色,以及如何在 "SideBarMenu" 上的项目被选中/突出显示时更改颜色。
根据您发布的示例 link 您可以尝试:
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;
}
')))
)
)
我评论了 CSS 以指出它修改的内容。
感谢 post。我认为您应该添加 "toggle button when hovered" 以使其完整。示例代码如下:
/* toggle button when hovered */
.skin-blue .main-header .navbar .sidebar-toggle:hover{
background-color: #ff69b4;
}
谢谢@NicE 的回答。另外:如果有人想控制侧边栏菜单选择左边框的颜色重音,border-left
属性 有效:
/* active selected tab in the sidebarmenu */
.skin-blue .main-sidebar .sidebar .sidebar-menu .active a{
background-color: #2e6984;
border-left: 3px solid #254264;
}
/* other links in the sidebarmenu */
.skin-blue .main-sidebar .sidebar .sidebar-menu a{
background-color: #3E8CB0;
color: #FFFFFF;
}
/* other links in the sidebarmenu when hovered */
.skin-blue .main-sidebar .sidebar .sidebar-menu a:hover{
background-color: #2e6984;
border-left: 3px solid #254264;
}
也许这个包可以进一步帮助你:
https://github.com/dreamRs/fresh
它允许很好地设置自定义主题和颜色,而无需自己处理 CSS 定义 - 但可以创建它们以供重复使用。
可在此处找到更多信息(相当详尽的一本书,主题更多!):https://unleash-shiny.rinterface.com/beautify-with-fresh.html