0

I have an R Shiny app with a collapsed navbarPage as described here. Now I would appreciate to have the menu collapsing on its own as soon as the cursor moves away from it rather than collapsing it manually. I have seen a couple of solutions for other frameworks, but does someone know how to solve this with R Shiny?

A simple example app here:

library(shiny)

navbar_js <- "@media (max-width: 12000px) {
    .navbar-header {
        float: none;
    }
    .navbar-left,.navbar-right {
        float: none !important;
    }
    .navbar-toggle {
        display: block;
    }
    .navbar-collapse {
        border-top: 1px solid transparent;
        box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
    }
    .navbar-fixed-top {
        top: 0;
        border-width: 0 0 1px;
    }
    .navbar-collapse.collapse {
        display: none!important;
    }
    .navbar-nav {
        float: none!important;
        margin-top: 7.5px;
    }
    .navbar-nav>li {
        float: none;
    }
    .navbar-nav>li>a {
        padding-top: 10px;
        padding-bottom: 10px;
    }
    .collapse.in{
        display:block !important;
    }
}"

ui <- navbarPage("App title",
                 collapsible = TRUE,
                 tabPanel("Panel 1"),
                 tabPanel("Panel 2"),
                 tabPanel("Panel 3"),
                 tags$head(tags$style(HTML(navbar_js))))

server <- function(input, output) {}

shinyApp(ui = ui, server = server)

Thank you :)

bathyscapher
  • 423
  • 4
  • 10

0 Answers0