shinydashboardPlus
shinydashboardPlus copied to clipboard
Hide text in sidebar when collapsed
Hi, I've added some HTML texts to the left sidebar and I would like the text to disappear when the sidebar is collapsed (otherwise it doesn't show properly). Is there a way to do that?
See the information section in the sidebar below.
![Screenshot 2021-05-27 at 11 18 41 AM](https://user-images.githubusercontent.com/80864619/119751072-d7a69300-bedd-11eb-9f60-55df11072ed8.png)
You can use shinyjs
to do this:
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyjs)
shinyApp(
ui = dashboardPage(
header = dashboardHeader(),
sidebar = dashboardSidebar(
id = "sidebar",
p("hello this is some text that just serves as a reprex", id = "info")
),
body = dashboardBody(
useShinyjs()
)
),
server = function(input, output, session) {
observeEvent(input$sidebar, {
toggle("info")
})
}
)