Skip to content

Commit

Permalink
Update app.R
Browse files Browse the repository at this point in the history
  • Loading branch information
daattali authored Nov 23, 2016
1 parent 1f5161f commit 804264b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions navbar-add-text/app.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
library(shiny)

# Call this function with all the regular navbarPage() parameters, plus a text parameter,
# if you want to add text to the navbar
navbarPageWithText <- function(..., text) {
navbar <- navbarPage(...)
textEl <- tags$p(class = "navbar-text", text)
Expand All @@ -8,6 +10,17 @@ navbarPageWithText <- function(..., text) {
navbar
}

# Call this function with an input (such as `textInput("text", NULL, "Search")`) if you
# want to add an input to the navbar
navbarPageWithInputs <- function(..., inputs) {
navbar <- navbarPage(...)
form <- tags$form(class = "navbar-form", inputs)
navbar[[3]][[1]]$children[[1]] <- htmltools::tagAppendChild(
navbar[[3]][[1]]$children[[1]], form)
navbar
}

# When creating the UI, call our wrapper function instead of `navbarPage()`
ui <- navbarPageWithText(
"Test app",
tabPanel("tab1", "tab 1"),
Expand Down

0 comments on commit 804264b

Please sign in to comment.