26

(来自闪亮的谷歌群组的交叉帖子)

有人可以指出我必须修改闪亮仪表板颜色的标签名称吗?

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;
                              }
                              ')))

我不清楚如何将标题和侧边栏的其余部分更改为橙色,以及如何在选择/突出显示“SideBarMenu”上的项目时更改颜色。

4

4 回答 4

69

根据您发布链接的示例,您可以尝试:

用户界面

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 以指出它修改了什么。

于 2015-07-30T14:05:22.967 回答
5

谢谢你的帖子。我认为您应该添加“悬停时切换按钮”以使其完成。示例代码如下:

/* toggle button when hovered  */                    
.skin-blue .main-header .navbar .sidebar-toggle:hover{
  background-color: #ff69b4;
}
于 2016-03-31T18:44:24.393 回答
1

谢谢@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;
                                  }

于 2020-10-23T06:20:58.707 回答
0

也许这个包可以帮助你进一步:

https://github.com/dreamRs/fresh

它允许很好地设置自定义主题和颜色,而无需自己处理 CSS 定义 - 但可以创建它们以供重复使用。

可以在此处找到更多信息(一本包含更多主题的详尽书籍!):https ://unleash-shiny.rinterface.com/beautify-with-fresh.html

于 2021-06-07T13:37:37.413 回答