R/wa_badge.R

Defines functions wa_badge

Documented in wa_badge

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

#' Create a `wa-badge` component
#'
#' Generated wrapper for the Web Awesome `wa-badge` component.
#' Generated from Web Awesome metadata.
#'
#' @param ... Child content for the component's default slot.
#' @param id Optional DOM id attribute for HTML, CSS, and JS targeting.
#' @param class Optional CSS class string.
#' @param style Optional inline CSS style string.
#' @param appearance Enumerated string. Allowed values: `accent`,
#' `filled`, `filled-outlined`, `outlined`. Default: `accent`. The badge's
#' visual appearance.
#' @param attention Enumerated string. Allowed values: `bounce`, `none`,
#' `pulse`. Default: `none`. Adds an animation to draw attention to the
#' badge.
#' @param dir String. Optional Web Awesome attribute.
#' @param lang String. Optional Web Awesome attribute.
#' @param pill Boolean. Default: `FALSE`. Draws a pill-style badge with
#' rounded edges.
#' @param variant Enumerated string. Allowed values: `brand`, `danger`,
#' `neutral`, `success`, `warning`. Default: `brand`. The badge's theme
#' variant. Defaults to `brand` if not within another element with a
#' variant.
#' @param end An element, such as `<wa-icon>`, placed after the label.
#' @param start An element, such as `<wa-icon>`, placed before the label.
#'
#' @section Shiny Bindings:
#' None.
#'
#' @return An HTML tag for the component.
#'
#' @export
wa_badge <- function(
  ...,
  id = NULL,
  class = NULL,
  style = NULL,
  appearance = NULL,
  attention = NULL,
  dir = NULL,
  lang = NULL,
  pill = NULL,
  variant = NULL,
  end = NULL,
  start = NULL
) {
  children <- list(...)
  children <- c(
    children,
    list(
      .wa_slot(end, "end")
    )
  )
  children <- c(
    children,
    list(
      .wa_slot(start, "start")
    )
  )

  if (!is.null(appearance)) {
    appearance <- .wa_match_arg(
      appearance,
      "appearance",
      c(
        "accent",
        "filled",
        "filled-outlined",
        "outlined"
      )
    )
  }

  if (!is.null(attention)) {
    attention <- .wa_match_arg(
      attention,
      "attention",
      c(
        "bounce",
        "none",
        "pulse"
      )
    )
  }

  if (!is.null(variant)) {
    variant <- .wa_match_arg(
      variant,
      "variant",
      c(
        "brand",
        "danger",
        "neutral",
        "success",
        "warning"
      )
    )
  }

  attrs <- .wa_normalize_attrs(
    list(
      "id" = id,
      "class" = class,
      "style" = style,
      "appearance" = appearance,
      "attention" = attention,
      "dir" = dir,
      "lang" = lang,
      "pill" = pill,
      "variant" = variant
    ),
    boolean_names = c("pill"),
    boolean_arg_names = c("pill" = "pill")
  )

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