删除切换齿轮图标控制栏
remove toggle gear icon controlbar
我正在尝试自定义我的 R shiny 应用程序的外观并尝试使用页面上的各种元素。
只是想知道如何从 header 中删除这个切换图标?我已经尝试过类似的方法,但它不起作用:
shinyjs::runjs("document.getElementsByClassName('skin-blue sidebar-mini')[0].style.visibility = 'hidden';")
可重现的例子:
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyjs)
library(DT)
ui <- shinydashboardPlus::dashboardPage(
options = list(sidebarExpandOnHover = TRUE),
header = dashboardHeader(
tags$li(
id = 'right-sidebar-toggle-list-item',
class = "dropdown",
actionLink("rightSidebarToggle", "Select Population"))
),
shinydashboardPlus::dashboardSidebar( disable = TRUE ,
sidebarMenu(
selectInput(
"countries", label = "Select Countries",
choices = c("B", "C", "A"), selected = "A",
multiple = TRUE
))
),# minified = TRUE, collapsed = F),
controlbar = shinydashboardPlus::dashboardControlbar(id = "controlbar", collapsed = F,
skin = "dark",
controlbarMenu(
id = "menu",
controlbarItem(
"Tab 1",
"Welcome to tab 1"
),
controlbarItem(
"Tab 2",
"Welcome to tab 2"
)
)
),
shinydashboard::dashboardBody(
useShinyjs(),
tabsetPanel( id="tabset",
tabPanel("Resource Allocation", value="tab1", plotOutput("plot")),
)
),
# controlbar = dashboardControlbar(collapsed = F),
title = "DashboardPage"
)
server <- function(input, output) {
output$plot <- renderPlot(plot(cars))
}
shinyApp(ui, server)
我们可以通过tags$script
使用一些JS来隐藏图标:
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyjs)
library(DT)
ui <- shinydashboardPlus::dashboardPage(
options = list(sidebarExpandOnHover = TRUE),
shinydashboardPlus::dashboardHeader(
tags$li(
id = 'right-sidebar-toggle-list-item',
class = "dropdown",
actionLink("rightSidebarToggle", "Select Population"))
),
shinydashboardPlus::dashboardSidebar(disable = TRUE ,
sidebarMenu(
selectInput(
"countries",
label = "Select Countries",
choices = c("B", "C", "A"),
selected = "A",
multiple = TRUE
)
)),
# minified = TRUE, collapsed = F),
controlbar = shinydashboardPlus::dashboardControlbar(
id = "controlbar",
collapsed = F,
skin = "dark",
controlbarMenu(
id = "menu",
controlbarItem("Tab 1",
"Welcome to tab 1"),
controlbarItem("Tab 2",
"Welcome to tab 2")
)
),
shinydashboard::dashboardBody(
useShinyjs(),
# hide icon
# tags$script(
# HTML(
# 'var e = document.querySelector("body > div.wrapper > header > nav > div:nth-child(4) > ul > li > a > i");
# e.setAttribute("style", "display: none;");'
# )
# ),
# hide hyperlink
tags$script(HTML('var e = document.querySelector("body > div.wrapper > header > nav > div:nth-child(4) > ul > li:last-child > a");
e.setAttribute("style", "display: none;");')),
tabsetPanel(
id = "tabset",
tabPanel("Resource Allocation", value = "tab1", plotOutput("plot")),
)
),
# controlbar = dashboardControlbar(collapsed = F),
title = "DashboardPage"
)
server <- function(input, output) {
output$plot <- renderPlot(plot(cars))
}
shinyApp(ui, server)
我正在尝试自定义我的 R shiny 应用程序的外观并尝试使用页面上的各种元素。
只是想知道如何从 header 中删除这个切换图标?我已经尝试过类似的方法,但它不起作用:
shinyjs::runjs("document.getElementsByClassName('skin-blue sidebar-mini')[0].style.visibility = 'hidden';")
可重现的例子:
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyjs)
library(DT)
ui <- shinydashboardPlus::dashboardPage(
options = list(sidebarExpandOnHover = TRUE),
header = dashboardHeader(
tags$li(
id = 'right-sidebar-toggle-list-item',
class = "dropdown",
actionLink("rightSidebarToggle", "Select Population"))
),
shinydashboardPlus::dashboardSidebar( disable = TRUE ,
sidebarMenu(
selectInput(
"countries", label = "Select Countries",
choices = c("B", "C", "A"), selected = "A",
multiple = TRUE
))
),# minified = TRUE, collapsed = F),
controlbar = shinydashboardPlus::dashboardControlbar(id = "controlbar", collapsed = F,
skin = "dark",
controlbarMenu(
id = "menu",
controlbarItem(
"Tab 1",
"Welcome to tab 1"
),
controlbarItem(
"Tab 2",
"Welcome to tab 2"
)
)
),
shinydashboard::dashboardBody(
useShinyjs(),
tabsetPanel( id="tabset",
tabPanel("Resource Allocation", value="tab1", plotOutput("plot")),
)
),
# controlbar = dashboardControlbar(collapsed = F),
title = "DashboardPage"
)
server <- function(input, output) {
output$plot <- renderPlot(plot(cars))
}
shinyApp(ui, server)
我们可以通过tags$script
使用一些JS来隐藏图标:
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyjs)
library(DT)
ui <- shinydashboardPlus::dashboardPage(
options = list(sidebarExpandOnHover = TRUE),
shinydashboardPlus::dashboardHeader(
tags$li(
id = 'right-sidebar-toggle-list-item',
class = "dropdown",
actionLink("rightSidebarToggle", "Select Population"))
),
shinydashboardPlus::dashboardSidebar(disable = TRUE ,
sidebarMenu(
selectInput(
"countries",
label = "Select Countries",
choices = c("B", "C", "A"),
selected = "A",
multiple = TRUE
)
)),
# minified = TRUE, collapsed = F),
controlbar = shinydashboardPlus::dashboardControlbar(
id = "controlbar",
collapsed = F,
skin = "dark",
controlbarMenu(
id = "menu",
controlbarItem("Tab 1",
"Welcome to tab 1"),
controlbarItem("Tab 2",
"Welcome to tab 2")
)
),
shinydashboard::dashboardBody(
useShinyjs(),
# hide icon
# tags$script(
# HTML(
# 'var e = document.querySelector("body > div.wrapper > header > nav > div:nth-child(4) > ul > li > a > i");
# e.setAttribute("style", "display: none;");'
# )
# ),
# hide hyperlink
tags$script(HTML('var e = document.querySelector("body > div.wrapper > header > nav > div:nth-child(4) > ul > li:last-child > a");
e.setAttribute("style", "display: none;");')),
tabsetPanel(
id = "tabset",
tabPanel("Resource Allocation", value = "tab1", plotOutput("plot")),
)
),
# controlbar = dashboardControlbar(collapsed = F),
title = "DashboardPage"
)
server <- function(input, output) {
output$plot <- renderPlot(plot(cars))
}
shinyApp(ui, server)