1.皮肤

shinydashboard有很多颜色主题和外观的设置。默认为蓝色,可指定黑丝、紫色、绿色、红色和黄色,如dashboardPage(skin = "black")

个人认为还是蓝色显得稳重一点。

2.注销面板

当使用Shiny Server Pro运行Shinydashboard应用程序并且登录了经过身份验证的用户时,在右上角将出现一个显示用户名和注销链接的面板。默认的Shiny Server Pro注销面板:



如果想改为添加具有动态UI(在服务器上生成)的用户面板,并隐藏默认的注销面板,如下所示:

library(shinydashboard)

ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
# Custom CSS to hide the default logout panel
tags$head(tags$style(HTML('.shiny-server-account { display: none; }'))), # The dynamically-generated user panel
uiOutput("userpanel")
),
dashboardBody()
) server <- function(input, output, session) {
output$userpanel <- renderUI({
# session$user is non-NULL only in authenticated sessions
if (!is.null(session$user)) {
sidebarUserPanel(
span("Logged in as ", session$user),
subtitle = a(icon("sign-out"), "Logout", href="__logout__"))
}
})
} shinyApp(ui, server)

3.CSS

可以通过在应用程序中创建www/子目录,并在其中添加CSS文件,将自定义CSS添加到应用程序中。例如,想将dashboard的标题字体更改为与其余部分相同的字体,如下图所示:



首先创建一个名为www/custom.css的文件,包含以下内容:

.main-header .logo {
font-family: "Georgia", Times, "Times New Roman", serif;
font-weight: bold;
font-size: 24px;
}

然后从UI引用该CSS文件:

## ui.R ##
dashboardPage(
dashboardHeader(title = "Custom font"),
dashboardSidebar(),
dashboardBody(
tags$head(
tags$link(rel = "stylesheet", type = "text/css", href = "custom.css")
)
)
)

或者直接将CSS脚本嵌套再UI代码中:

## ui.R ##
dashboardPage(
dashboardHeader(title = "Custom font"),
dashboardSidebar(),
dashboardBody(
tags$head(tags$style(HTML('
.main-header .logo {
font-family: "Georgia", Times, "Times New Roman", serif;
font-weight: bold;
font-size: 24px;
}
')))
)
)

更多CSS的个性化设置可参考:Style your apps with CSS

4. 标题延长

很多情况下,shinydashboard使用的标题会超出标题栏中的默认宽度。可以使用titleWidth增加宽度。

如下图,将标题增加到450像素,并且通过使用自定义CSS将标题区域的背景色设置为与标题栏的其余部分相同:

shinyApp(
ui = dashboardPage(
dashboardHeader(
title = "Example of a long title that needs more space",
titleWidth = 450
),
dashboardSidebar(),
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('
.skin-blue .main-header .logo {
background-color: #3c8dbc;
}
.skin-blue .main-header .logo:hover {
background-color: #3c8dbc;
}
')))
)
),
server = function(input, output) { }
)

5.侧边栏宽度

通过使用width参数。

shinyApp(
ui = dashboardPage(
dashboardHeader(
title = "Title and sidebar 350 pixels wide",
titleWidth = 350
),
dashboardSidebar(
width = 350,
sidebarMenu(
menuItem("Menu Item")
)
),
dashboardBody()
),
server = function(input, output) { }
)

6.图标

Shiny和Shinydashboard中使用的图标实际上只是特殊字体集中的字符,它们是由Shiny的icon()创建的。

icon("calendar")
对应的HTML
<i class="fa fa-calendar"></i>

默认情况下,icon()使用的是Font-Awesome中的图标,如果要使用Glyphicons,需要指定lib="glyphicon":

"Calendar from Font-Awesome:", icon("calendar"),
"Cog from Glyphicons:", icon("cog", lib = "glyphicon")

来自Font-Awesome的图标:http://fontawesome.io/icons/

来自Glyphicons的图标: http://getbootstrap.com/components/#glyphicons

7.状态和颜色

Shinydashboard组件的状态参数status,是某些Bootstrap类的属性。如status="primary",status="success":



Shinydashboard组件的颜色参数color,如color="red",color="black":



更多状态和颜色通过?validStatuses?validColors查看。

Ref:

https://rstudio.github.io/shinydashboard/appearance.html

最新文章

  1. Spring Batch在大型企业中的最佳实践
  2. java开发人员,最应该学习和熟练使用的工具类。google guava.(谷歌 瓜娃)
  3. struts 异常机制
  4. 20个设计精致的用户界面 PSD 源文件免费下载
  5. OC NSArray 数组
  6. DB2 create partitioned table
  7. lucene 区分大小写 问题以及解决方案
  8. Andoid自动判断输入是电话,网址或者Email的方法----Linkify的应用!
  9. [Android][Audio] audio_policy.conf文件分析
  10. HDU 1165 Eddy&#39;s research II
  11. SQLiteLog (1) no such Column:
  12. 201521123067 《Java程序设计》第2周学习总结
  13. .Net 关于 InfoPath 的基本使用
  14. EOS智能合约开发(三):EOS创建和管理账号
  15. pyspider操作千万级库,pyspider在对接量级较大库的策略
  16. Python下HttpHTTPClient和AsyncHTTPClient
  17. java对象的六大原则
  18. RestTemplate异常no suitable HttpMessageConverter found for request type [java.lang.Integer]
  19. WCF3.5 SP1 参考源码索引
  20. windows使用IPC和文件共享

热门文章

  1. 设置nginx进程可打开最大的文件数
  2. js基础学习之&quot;==&quot;与&quot;===&quot;的区别
  3. pyqgis学习细节
  4. Pandas核心用法
  5. Machine learning (8-Neural Networks: Representation)
  6. 一从二主IIC连接调试
  7. AtCoder Beginner Contest 210题解
  8. CSP2020-儒略历
  9. k8s中部署springcloud
  10. Jackson &amp; fastJson的使用