A toggleable dropdown menu input. Menu inputs may be used as standalone reactive inputs or within a navInput(). For building custom, more complex dropdown elements please see dropdown().

menuInput(
  id,
  label,
  choices = NULL,
  values = choices,
  selected = NULL,
  ...,
  direction = "down",
  align = "left"
)

updateMenuInput(
  id,
  label = NULL,
  choices = NULL,
  values = choices,
  selected = NULL,
  enable = NULL,
  disable = NULL,
  session = getDefaultReactiveDomain()
)

Arguments

id

A character string specifying the id of the reactive input.

label

A character string or tag element specifying the label of the menu's toggle button.

choices

A character vector specifying the choice text of the menu's items.

values

A character vector specifying the values of the menu's items, defaults to choices.

selected

One or more of values specifying which choices are selected by default, defaults to NULL, in which case no choices are initially selected.

...

Additional named arguments passed as HTML attributes to the parent element or tag elements passed as child elements to the parent element.

direction

One of "up", "right", "down", or "left" specifying which direction the menu opens, defaults to "down".

align

One or "right" or "left" specifying which side of the toggle button the menu aligns to, defaults to "left".`

enable

One of values specifying particular choices to enable or TRUE specifying the entire input is enabled, defaults to NULL.

disable

One of values specifying particular choices to disable or TRUE specifying the entire input is disabled, defaults to NULL.

session

A reactive context, defaults to getDefaultReactiveDomain().

See also

Examples

### A simple menu menuInput( id = "menu1", label = "Menu", choices = c( "Choice 1", "Choice 2", "Choice 3" ) )
#> <div class="yonder-menu dropdown" id="menu1"> #> <button class="btn btn-grey dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Menu</button> #> <div class="dropdown-menu"> #> <button class="dropdown-item" type="button" value="Choice 1">Choice 1</button> #> <button class="dropdown-item" type="button" value="Choice 2">Choice 2</button> #> <button class="dropdown-item" type="button" value="Choice 3">Choice 3</button> #> </div> #> </div>
### Use in navigation navInput( id = "nav1", choices = list( "Tab 1", menuInput( id = "navOptions", label = "Tab 2", choices = c( "Option 1", "Option 2", "Option 3" ) ), "Tab 3", "Tab 4" ), values = paste0("tab", 1:4) )
#> <ul class="yonder-nav nav" id="nav1"> #> <li class="nav-item"> #> <button class="nav-link btn btn-link active" value="tab1">Tab 1</button> #> </li> #> <li class="yonder-menu dropdown nav-item" id="navOptions"> #> <button class="btn dropdown-toggle nav-link btn-link" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" value="tab2">Tab 2</button> #> <div class="dropdown-menu"> #> <button class="dropdown-item" type="button" value="Option 1">Option 1</button> #> <button class="dropdown-item" type="button" value="Option 2">Option 2</button> #> <button class="dropdown-item" type="button" value="Option 3">Option 3</button> #> </div> #> </li> #> <li class="nav-item"> #> <button class="nav-link btn btn-link" value="tab3">Tab 3</button> #> </li> #> <li class="nav-item"> #> <button class="nav-link btn btn-link" value="tab4">Tab 4</button> #> </li> #> </ul>