shinydashboardPlus icon indicating copy to clipboard operation
shinydashboardPlus copied to clipboard

Hide text in sidebar when collapsed

Open racheldsoh opened this issue 3 years ago • 1 comments

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

racheldsoh avatar May 27 '21 01:05 racheldsoh

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")
    })
    
  }
)

etiennebacher avatar Apr 30 '22 19:04 etiennebacher