To build a new menu, give new_nav_menu()
unique keys and a list of their
corresponding values.
Each line shows the menu items (keys on the left, value descriptions on the
right).
By default, the description from pillar::obj_sum()
is displayed, but you
can set description
.
Each menu item can be accessed by activate()
.
Usage
new_nav_menu(
key = character(),
value = list(data.frame()),
description = NULL,
attrs = NULL,
...,
class = character()
)
Arguments
- key
A unique character vector.
- value
A list of values corresponding to the keys.
- description
A character vector of descriptions for the keys. By default, the description from
pillar::obj_sum()
is displayed.- attrs
A data frame for additional attributes of items (an empty data frame by default). When an item becomes active, the attrs will be added to its attributes.
- ...
Additional arguments passed to
vctrs::new_data_frame()
.- class
A character vector of subclasses passed to
vctrs::new_data_frame()
.
Examples
library(dplyr)
band <- new_nav_menu(
key = c("band_members", "band_instruments"),
value = list(band_members, band_instruments),
description = c(
"A data frame of band members",
"A data frame of band instruments"
)
)
band
#> # ☐ band_members: A data frame of band members
#> # ☐ band_instruments: A data frame of band instruments
#> #
#> # Please `activate()`.
# You can also build a nested menu
bands <- new_nav_menu(
key = c("key1", "key2"),
value = list(band, band)
)
bands
#> # ☐ key1: nav_menu [2]
#> # ☐ key2: nav_menu [2]
#> #
#> # Please `activate()`.