Skip to content
menubars for shiny apps
R JavaScript CSS
Branch: master
Clone or download
Latest commit aaf4209 Apr 10, 2015
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R Added submenus Apr 10, 2015
inst Added submenus Apr 10, 2015
man many changes; context menus working, dropdowns recreated to be more f… Apr 9, 2015
.Rbuildignore Initial Commit Mar 20, 2015
.gitignore Initial Commit Mar 20, 2015
DESCRIPTION updated urls Apr 7, 2015
NAMESPACE Added submenus Apr 10, 2015
README.md
shinyMenus.Rproj rename updates Apr 7, 2015

README.md

shinyMenus

menus for shiny apps

I've renamed the repository from shinyMB to shinyMenus to be more discriptive and to reflect the fact that it isn't just menu bars, but other menus as well.

This is loosely based on the bsNavBar functions that used to be part of shinyBS. It is just a beginning but hopefully it will eventually be an improvement to those functions.

The idea is that you will be able to add standard shiny inputs to a menubar and shinyMB will make the necessary changes to make them work within the menubar. There will also be dropdowns that work like actionButtons, checkboxGroupInputs, or radioButtons. I hope also to reintroduce the ability to nest dropdowns, a feature that was removed from bootstrap3.

Install it with devtools:

devtools::install_github("ebailey78/shinyMenus")

Here is an example that shows what the package can do so far:

library(shiny)
library(shinyBS)
library(shinyMenus)

app <- shinyApp(
  ui = 
    fluidPage(
      smNavBar("testMenu", "shinyMB", full.width = TRUE, fixed = FALSE, 
              actionLink("testLink", "Link"),
              actionLink("testLink2", "Link #2"),
              textInput("n", "Sample Size", value = 1000),
              smNavDropdown("Distribution",
                 smRadio("dist", "norm", "Normal", selected = TRUE),
                 smRadio("dist", "lnorm", "Lognormal"),
                 smRadio("dist", "unif", "Uniform")
              ),
              smQuickDropdown("qd2Test", parent = "navbar", "Quick Dropdown", c("Action 1", "Action 2", "Action 3"))
      ),
      smDropdown(actionLink("ddTest", "Dropdown"),
                 smHeader("Action Elements"),
                 smAction("action1", "Action"),
                 smAction("action2", "Another Action"),
                 smDivider(),
                 smHeader("Checkbox Elements"),
                 smCheckbox("testCB", "cb1", "First Checkbox"),
                 smCheckbox("testCB", "cb2", "Second Checkbox"),
                 smCheckbox("testCB", "cb3", "Third Checkbox", selected = TRUE),
                 smDivider(),
                 smHeader("More Checkboxes"),
                 smCheckbox("testCB2", "cb21", "First Checkbox", selected = TRUE),
                 smCheckbox("testCB2", "cb22", "Second Checkbox", selected = TRUE),
                 smCheckbox("testCB2", "cb23", "Third Checkbox"),
                 smDivider(),
                 smHeader("Radio Elements"),
                 smRadio("testRB", "rb1", "First Radio"),
                 smRadio("testRB", "rb2", "Second Radio", selected = TRUE),
                 smRadio("testRB", "rb3", "Third Radio", selected = TRUE)
      ),
      smQuickDropdown("qdTest", "Quick Dropdown", c("Action 1", "Action 2", "Action 3")),
      plotOutput("testPlot"),
      smContextMenu("context1", "testPlot", 
                    smRadio("dist", "norm", "Normal", selected = TRUE),
                    smRadio("dist", "lnorm", "Lognormal"),
                    smRadio("dist", "unif", "Uniform")
      )

    ),
  server = 
    function(input, output, session) {
      observeEvent(input$testCB2, ({print(input$testCB2)}))
      observeEvent(input$testRB, ({print(input$testRB)}))
      observeEvent(input$qdTest, ({print(input$qdTest)}))
      observeEvent(input[["Action 1"]], ({print(input[["Action 1"]])}))
      output$testPlot <- renderPlot({
        dist <- switch(input$dist,
                       norm = rnorm,
                       lnorm = rlnorm,
                       unif = runif
        )
        plot(dist(input$n))
      })
    }
)

runApp(app)

If you have ideas or suggestions please let me know in the issues section.

You can’t perform that action at this time.