R/wa_checkbox.R

Defines functions wa_checkbox

Documented in wa_checkbox

# Generated by tools/generate_components.R. Do not edit by hand.
# nolint start: object_usage_linter.

#' Create a `wa-checkbox` component
#'
#' Generated wrapper for the Web Awesome `wa-checkbox` component. When
#' used as a Shiny input, `input$<input_id>` reflects the component's
#' current `value` value. The Shiny value is returned as a logical value.
#' Generated from Web Awesome metadata.
#'
#' @param ... Child content for the component's default slot.
#' @param input_id Shiny input id for the component. This is also used as
#' the rendered DOM `id` attribute.
#' @param class Optional CSS class string.
#' @param style Optional inline CSS style string.
#' @param value String. The value of the checkbox, submitted as a
#' name/value pair with form data.
#' @param checked Boolean. Default: `FALSE`. The default value of the form
#' control. Primarily used for resetting the form control. This wrapper
#' argument sets the HTML `checked` attribute, which maps to the
#' component's `defaultChecked` field/property rather than its live
#' `checked` property.
#' @param disabled Boolean. Default: `FALSE`. Disables the checkbox.
#' @param hint String. Default: `""`. The checkbox's hint. If you need to
#' display HTML, use the `hint` slot instead.
#' @param name String. Default: `null`. The name of the checkbox,
#' submitted as a name/value pair with form data.
#' @param custom_error String. Default: `null`. Optional Web Awesome
#' attribute.
#' @param dir String. Optional Web Awesome attribute.
#' @param indeterminate Boolean. Default: `FALSE`. Draws the checkbox in
#' an indeterminate state. This is usually applied to checkboxes that
#' represents a "select all/none" behavior when associated checkboxes have
#' a mix of checked and unchecked states.
#' @param lang String. Optional Web Awesome attribute.
#' @param required Boolean. Default: `FALSE`. Makes the checkbox a
#' required field.
#' @param size Enumerated string. Allowed values: `large`, `medium`,
#' `small`. Default: `medium`. The checkbox's size.
#' @param title String. Default: `""`. Optional Web Awesome attribute.
#' @param hint_slot Text that describes how to use the checkbox.
#' Alternatively, you can use the `hint` attribute.
#'
#' @section Shiny Bindings:
#' `input$<input_id>` reflects the component's current `value` value. The
#' Shiny value is returned as a logical value.
#'
#' @return An HTML tag for the component.
#'
#' @export
wa_checkbox <- function(
  input_id,
  ...,
  class = NULL,
  style = NULL,
  value = NULL,
  checked = NULL,
  disabled = NULL,
  hint = NULL,
  name = NULL,
  custom_error = NULL,
  dir = NULL,
  indeterminate = NULL,
  lang = NULL,
  required = NULL,
  size = NULL,
  title = NULL,
  hint_slot = NULL
) {
  children <- list(...)
  children <- c(
    children,
    list(
      .wa_slot(hint_slot, "hint")
    )
  )

  if (!is.null(size)) {
    size <- .wa_match_arg(
      size,
      "size",
      c(
        "large",
        "medium",
        "small"
      )
    )
  }

  attrs <- .wa_normalize_attrs(
    list(
      "id" = input_id,
      "class" = class,
      "style" = style,
      "value" = value,
      "checked" = checked,
      "disabled" = disabled,
      "hint" = hint,
      "name" = name,
      "custom-error" = custom_error,
      "dir" = dir,
      "indeterminate" = indeterminate,
      "lang" = lang,
      "required" = required,
      "size" = size,
      "title" = title
    ),
    boolean_names = c(
      "checked",
      "disabled",
      "indeterminate",
      "required"
    ),
    boolean_arg_names = c(
      "checked" = "checked",
      "disabled" = "disabled",
      "indeterminate" = "indeterminate",
      "required" = "required"
    )
  )

  do.call(
    .wa_component,
    c(
      list("wa-checkbox", .attrs = attrs),
      children
    )
  )
}
# nolint end

Try the shiny.webawesome package in your browser

Any scripts or data that you put into this service are public.

shiny.webawesome documentation built on April 22, 2026, 1:09 a.m.