Put checkboxInput in NavbarPage

Does anyone have a good solution for putting the checkboxInput into the navbarPage in such a way that it is clickable in the navbar? The sample below is sorta what I want, but the code fails with the checkbox in navbar

library(shiny)
library(bslib)

ui <- fluidPage(

navbarPage(
theme = bs_theme(bootswatch = "flatly"),
title = 'Methods',
tabPanel('One'),
tabPanel('Two'),
tabPanel('Three'),
tabPanel('Four'),
checkboxInput('aCheckBox', 'Check Me', TRUE)
),
mainPanel(
h1('Hello World'),
fileInput("file", "Choose CSV File", accept = ".csv"),
actionButton('aButton', 'Do Stuff'),
submitButton("Submit"),
actionButton("primary", "Primary", class = "btn-primary m-2"),
#checkboxInput('aCheckBox', 'Check Me', TRUE)
)
)

server <- function(input, output) {

}

shinyApp(ui = ui, server = server)

I was able to find a solution using nav_item as follows


ui <- fluidPage(

navbarPage(
theme = bs_theme(bootswatch = "flatly"),
title = 'Methods',
tabPanel('One'),
tabPanel('Two'),
tabPanel('Three'),
tabPanel('Four'),
nav_item(checkboxInput('aCheckBox', 'Check Me', FALSE))
),
mainPanel(
h1('Hello World'),
fileInput("file", "Choose CSV File", accept = ".csv"),
actionButton('aButton', 'Do Stuff'),
submitButton("Submit"),
actionButton("primary", "Primary", class = "btn-primary m-2"),
)
)

server <- function(input, output) {

}

shinyApp(ui = ui, server = server)

The only problem I cannot figure out from documentation is how to make the text in the nav_bar item be the same as the theme selected (e.g., flatly) in this case.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.