From 804264b348eb574834bcf3974c298e0c4f3ec8a6 Mon Sep 17 00:00:00 2001 From: Dean Attali Date: Wed, 23 Nov 2016 00:16:44 -0500 Subject: [PATCH] Update app.R --- navbar-add-text/app.R | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/navbar-add-text/app.R b/navbar-add-text/app.R index a4cc4ca..eebdacf 100644 --- a/navbar-add-text/app.R +++ b/navbar-add-text/app.R @@ -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) @@ -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"),