#' @title
#' Bulma Form: Select
#'
#' @description
#' The browser built-in select dropdown, styled accordingly. The select class is
#' a simple wrapper around the `<select>` HTML element, which gives the styling
#' more flexibility and support for icons.
#'
#' [Select](https://bulma.io/documentation/form/select/)
#'
#' @family Bulma Form Components
#' @name bulma_form_select
NULL
#' @describeIn bulma_form_select main container; contains `bulma_form_option()`
#'
#' @param rows (int) how many options to make visible
#' @param rounded (flg) rounded select
#' @param multiple (flg) can select multiple?
#' @param outer_tag,inner_tag (fun) default HTML tags
#' @inheritParams bulma_form_textarea
#'
#' @export
bulma_form_select <- function(name,
...,
rows = NULL,
rounded = FALSE,
readonly = FALSE,
disabled = FALSE,
multiple = FALSE,
color = c("primary", "link", "info",
"success", "warning", "danger",
"white", "black", "light", "dark"),
size = c("small", "normal", "medium", "large"),
state = c("hovered", "focused", "active",
"loading", "static"),
outer_tag = tags$div,
inner_tag = tags$select) {
assert_string(name)
assert_function(outer_tag)
assert_function(inner_tag)
assert_int(rows, null.ok = TRUE)
color <- match_arg(color)
size <- match_arg(size)
state <- match_arg(state)
walk(unnamed(...),
assert_multi_class,
c("bulma_form_option"))
outer_tag(
class = "select",
inner_tag(..., size = rows, name = name) %>%
when(multiple, tagAppendAttributes(., multiple = NA))
) %>%
bulma_color(color) %>%
bulma_size(size) %>%
bulma_state(state) %>%
when(rounded, bulma_is(., "rounded")) %>%
when(readonly, bulma_readonly(.)) %>%
when(disabled, bulma_disabled(.)) %>%
when(multiple, bulma_is(., "multiple")) %>%
add_class("bulma_form_select")
}
#' @describeIn bulma_form_select the option inside the select
#'
#' @param value (scalar) machine value for the value
#'
#' @export
bulma_form_select_option <- function(..., value = NULL, tag = tags$option) {
assert_function(tag)
assert_string(value, null.ok = TRUE)
tag(value = value, ...) %>%
add_class("bulma_form_option")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.