Skip to contents

Dropdown Input Form Group

Usage

inp_dropdown(kv, label = NULL, width = 4, ...)

Arguments

kv

a vector, a list or a dataframe

label

label for the form input - this will default to display the name of the variable

width

the form-group's width in bootstrap grid units

...

additional arguments passed to the form group parser

Value

An object of class "appifyr_input" and "appifyr_dropdown_input"

Examples

inp_dropdown(c(1, 3, 7, 42))
#> $fg
#> [1] "dropdown"
#> 
#> $label
#> NULL
#> 
#> $width
#> [1] 4
#> 
#> $dots
#> list()
#> 
#> $opts
#> # A tibble: 4 × 2
#>     key value
#>   <dbl> <dbl>
#> 1     1     1
#> 2     3     3
#> 3     7     7
#> 4    42    42
#> 
#> attr(,"class")
#> [1] "appifyr_input"          "appifyr_dropdown_input"
inp_dropdown(names(iris), label = "Select Iris Variable")
#> $fg
#> [1] "dropdown"
#> 
#> $label
#> [1] "Select Iris Variable"
#> 
#> $width
#> [1] 4
#> 
#> $dots
#> list()
#> 
#> $opts
#> # A tibble: 5 × 2
#>   key          value       
#>   <chr>        <chr>       
#> 1 Sepal.Length Sepal.Length
#> 2 Sepal.Width  Sepal.Width 
#> 3 Petal.Length Petal.Length
#> 4 Petal.Width  Petal.Width 
#> 5 Species      Species     
#> 
#> attr(,"class")
#> [1] "appifyr_input"          "appifyr_dropdown_input"
kv <- data.frame(key = c("A", "B"), value = c(1, 2))
inp_dropdown(kv)
#> $fg
#> [1] "dropdown"
#> 
#> $label
#> NULL
#> 
#> $width
#> [1] 4
#> 
#> $dots
#> list()
#> 
#> $opts
#> # A tibble: 2 × 2
#>   key   value
#>   <chr> <dbl>
#> 1 A         1
#> 2 B         2
#> 
#> attr(,"class")
#> [1] "appifyr_input"          "appifyr_dropdown_input"
inp_dropdown(LETTERS, label = "Letters", width = 2)
#> $fg
#> [1] "dropdown"
#> 
#> $label
#> [1] "Letters"
#> 
#> $width
#> [1] 2
#> 
#> $dots
#> list()
#> 
#> $opts
#> # A tibble: 26 × 2
#>    key   value
#>    <chr> <chr>
#>  1 A     A    
#>  2 B     B    
#>  3 C     C    
#>  4 D     D    
#>  5 E     E    
#>  6 F     F    
#>  7 G     G    
#>  8 H     H    
#>  9 I     I    
#> 10 J     J    
#> # ℹ 16 more rows
#> 
#> attr(,"class")
#> [1] "appifyr_input"          "appifyr_dropdown_input"
inp_dropdown(list(n = 1, m = 2, k = 4))
#> $fg
#> [1] "dropdown"
#> 
#> $label
#> NULL
#> 
#> $width
#> [1] 4
#> 
#> $dots
#> list()
#> 
#> $opts
#> # A tibble: 3 × 2
#>   key   value
#>   <chr> <dbl>
#> 1 n         1
#> 2 m         2
#> 3 k         4
#> 
#> attr(,"class")
#> [1] "appifyr_input"          "appifyr_dropdown_input"