R/bulma-form-checkbox.R

Defines functions bulma_form_checkbox

Documented in bulma_form_checkbox

#' @title
#' Bulma Form: Checkbox
#'
#' @description
#' The 2-state checkbox in its native format.
#'
#' [Checkbox](https://bulma.io/documentation/form/checkbox/)
#'
#' @param name (str) human readable identifier for POST
#' @param ...  (tag) content
#' @param outer_tag,inner_tag (fun) default html tags
#' @param disabled (flg) whether checkable or not
#'
#' @family Bulma Form Components
#' @export
bulma_form_checkbox <- function(name,
                                ...,
                                disabled = FALSE,
                                outer_tag = tags$label,
                                inner_tag = tags$input) {

  assert_string(name)
  assert_function(outer_tag)
  assert_function(inner_tag)

  outer_tag(
    class = "checkbox",
    inner_tag(type = "checkbox", name = name) %>%
      when(disabled, bulma_disabled(.)),
    ...
  ) %>%
    when(disabled, bulma_disabled(.)) %>%
    add_class("bulma_form_checkbox")

}
tjpalanca/bulma.R documentation built on Dec. 23, 2021, 10:58 a.m.