I have a Shiny app that uses a navbarPage() structure with a fixed position, collapsible navbar. I want to be able to check within my server-side code whether the navbar is currently collapsed or not. I am using Bootstrap 4.
Here is some example code that illustrates the app set up, with some pseudo-code on the server side:
library(shiny)
library(bslib)
ui <- navbarPage(
title = "An app",
# Specifying Bootstrap 4, as solutions may differ
# by Bootstrap version
theme = bs_theme(version = "4"),
tabPanel(title = "A tab",
position = "fixed-top",
collapsible = TRUE,
"Some content")
)
server <- function(input, output, session) {
# PSEUDO-CODE:
# if (navbar_is_collapsed) {
# do something
# }
}
shinyApp(ui, server)
Created on 2021-06-15 by the reprex package (v2.0.0)
How can I check within server whether the navbar is collapsed or not?