This is a reimplementation of Shiny’s navbarPage and tabset functionality with more features and flexibility.
You can install shinynavbar with:
# install.packages("devtools")
devtools::install_github("markusdumke/shinynavbar")
Here is an example:
library(shiny)
library(shinynavbar)
ui <- bootstrapPage(
tags$head(tags$style(".active a {background-color: #f8f8f8 !important}
.navbar-brand {padding: 0 0 !important}")),
navbar(position = "static-top",
## use image as brand
navbarHeader(navbarBrand("Brand")),
## these elements appear on the right
navbarHeader(navbarButton("Logout"),
navbarCollapseButton(),
pull = "right"),
## the classical navbar with a text form
navbarCollapse(navbarNav(navTab("Tab1"),
navTab("Tab2"),
navTab("Tab3")),
navbarForm(textInputNoLabel("text")))
),
div(
class = "container-fluid",
divTabContent(
divTabPane("Tab1", h2("This is tab1")),
divTabPane("Tab2", h2("This is tab2")),
divTabPane("Tab3", h2("This is tab3"))
)
)
)
server <- function(input, output, session) {
session$onSessionEnded(stopApp)
observeEvent(input$navbar, {
print(input$navbar)
})
observeEvent(input$Logout, {
print("Logged out")
})
## clicked on brand image
observeEvent(input$Brand, {
print("Brand")
})
}
shinyApp(ui, server)