我下面有一个基本的闪亮仪表板,我想知道我是否可以向左或向右稍微左右bs按钮"显示/hide sidebar"。
#ui.r
library(shinydashboard)
library(shiny)
library(shinyBS)
dashboardPage(
dashboardHeader(),
dashboardSidebar(disable = TRUE),
dashboardBody(
tabsetPanel(
id = 'testingDPEtab',
tabPanel("Upload",
bsButton("showpanel8", "Show/Hide sidebar",icon = icon("toggle-off"), type = "toggle",style = "info", value = TRUE),
dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody())
)
)
))
#server.r
server <- function(input, output) { }
取决于要将"移动"应用于特定按钮还是可以执行的所有这些按钮:
tags$head(
tags$style(HTML('#showpanel8{margin-left:10px}'))
)
在这里,ID引用该按钮。因此,更改仅适用于该按钮。 #showpanel8{margin-left:10px}
是CSS语法,用于样式按钮。对于其他边距,您可以使用:
- 保证金顶
- 边缘右
- 边缘底
- 边距 - 左
请参阅此处:https://www.w3schools.com/css/css_margin.asp。
完整可重复的示例:
library(shinydashboard)
library(shiny)
library(shinyBS)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(disable = TRUE),
dashboardBody(
tags$head(
tags$style(HTML('#showpanel8{margin-left:10px}'))
),
tabsetPanel(
id = 'testingDPEtab',
tabPanel("Upload",
bsButton("showpanel8", "Show/Hide sidebar",
icon = icon("toggle-off"), type = "toggle",
style = "info", value = TRUE),
dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody())
)
)
))
#server.r
server <- function(input, output) { }
shinyApp(ui, server)