R/wa_radio_group.R

Defines functions wa_radio_group

Documented in wa_radio_group

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

#' Create a `wa-radio-group` component
#'
#' Generated wrapper for the Web Awesome `wa-radio-group` component. When
#' used as a Shiny input, `input$<input_id>` reflects the component's
#' current `value` 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 default value of the form control. Primarily
#' used for resetting the form control. This wrapper argument sets the
#' HTML `value` attribute, which maps to the component's `defaultValue`
#' field/property rather than its live `value` property.
#' @param disabled Boolean. Default: `FALSE`. Disables the radio group and
#' all child radios.
#' @param label String. Default: `""`. The radio group's label. Required
#' for proper accessibility. If you need to display HTML, use the `label`
#' slot instead.
#' @param hint String. Default: `""`. The radio groups's hint. If you need
#' to display HTML, use the `hint` slot instead.
#' @param name String. Default: `null`. The name of the radio group,
#' 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 lang String. Optional Web Awesome attribute.
#' @param orientation Enumerated string. Allowed values: `horizontal`,
#' `vertical`. Default: `vertical`. The orientation in which to show radio
#' items.
#' @param required Boolean. Default: `FALSE`. Ensures a child radio is
#' checked before allowing the containing form to submit.
#' @param size Enumerated string. Allowed values: `large`, `medium`,
#' `small`. The radio group's size. When present, this size will be
#' applied to all `<wa-radio>` items inside.
#' @param with_hint Boolean. Default: `FALSE`. Only required for SSR. Set
#' to `TRUE` if you're slotting in a `hint` element so the server-rendered
#' markup includes the hint before the component hydrates on the client.
#' @param with_label Boolean. Default: `FALSE`. Only required for SSR. Set
#' to `TRUE` if you're slotting in a `label` element so the
#' server-rendered markup includes the label before the component hydrates
#' on the client.
#' @param hint_slot Text that describes how to use the radio group.
#' Alternatively, you can use the `hint` attribute.
#' @param label_slot The radio group's label. Required for proper
#' accessibility. Alternatively, you can use the `label` attribute.
#'
#' @section Shiny Bindings:
#' `input$<input_id>` reflects the component's current `value` value.
#'
#' @return An HTML tag for the component.
#'
#' @export
wa_radio_group <- function(
  input_id,
  ...,
  class = NULL,
  style = NULL,
  value = NULL,
  disabled = NULL,
  label = NULL,
  hint = NULL,
  name = NULL,
  custom_error = NULL,
  dir = NULL,
  lang = NULL,
  orientation = NULL,
  required = NULL,
  size = NULL,
  with_hint = NULL,
  with_label = NULL,
  hint_slot = NULL,
  label_slot = NULL
) {
  children <- list(...)
  children <- c(
    children,
    list(
      .wa_slot(hint_slot, "hint")
    )
  )
  children <- c(
    children,
    list(
      .wa_slot(label_slot, "label")
    )
  )

  if (!is.null(orientation)) {
    orientation <- .wa_match_arg(
      orientation,
      "orientation",
      c(
        "horizontal",
        "vertical"
      )
    )
  }

  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,
      "disabled" = disabled,
      "label" = label,
      "hint" = hint,
      "name" = name,
      "custom-error" = custom_error,
      "dir" = dir,
      "lang" = lang,
      "orientation" = orientation,
      "required" = required,
      "size" = size,
      "with-hint" = with_hint,
      "with-label" = with_label
    ),
    boolean_names = c(
      "disabled",
      "required",
      "with-hint",
      "with-label"
    ),
    boolean_arg_names = c(
      "disabled" = "disabled",
      "required" = "required",
      "with-hint" = "with_hint",
      "with-label" = "with_label"
    )
  )

  do.call(
    .wa_component,
    c(
      list("wa-radio-group", .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.