如何在shinydashboard中将tabBox的标题置于标签页上方
解决方案
通过注入自定义CSS修改tabBox的默认布局即可实现需求,修改后的完整可运行代码如下:
library(shiny) library(shinydashboard) ui = dashboardPage( dashboardHeader(title = "tabBoxes"), dashboardSidebar(), dashboardBody( # 注入自定义CSS tags$head( tags$style(HTML(" .custom-tabbox .box-header { display: flex; flex-direction: column; align-items: flex-start; } .custom-tabbox .box-header > .box-title { float: none; margin-bottom: 10px; } ")) ), fluidRow( tabBox( title = HTML("Hello friend<br>"), # 给当前tabBox添加自定义类名,仅修改单个tabBox的样式 class = "custom-tabbox", tabPanel("merp", "hi there"), tabPanel("derp", "hello"), tabPanel("herp", "howdy") ) ) ) ) server = function(input, output) { output$tabset1Selected <- renderText({ input$tabset1 }) } shinyApp(ui = ui, server = server)
如果需要全局修改所有tabBox的标题位置,直接去掉CSS选择器里的.custom-tabbox前缀即可,不需要给每个tabBox单独添加自定义类。
内容的提问来源于stack exchange,提问作者Marissa
相关产品推荐
相关产品推荐

