R/wa_icon.R

Defines functions wa_icon

Documented in wa_icon

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

#' Create a `wa-icon` component
#'
#' Generated wrapper for the Web Awesome `wa-icon` 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 label String. Default: `""`. An alternate description to use for
#' assistive devices. If omitted, the icon will be considered
#' presentational and ignored by assistive devices.
#' @param name String. The name of the icon to draw. Available names
#' depend on the icon library being used.
#' @param animation Enumerated string. Allowed values: `beat`,
#' `beat-fade`, `bounce`, `fade`, `flip`, `shake`, `spin`, `spin-pulse`,
#' `spin-reverse`. Sets the animation for the icon
#' @param auto_width Boolean. Default: `FALSE`. Sets the width of the icon
#' to match the cropped SVG viewBox. This operates like the Font
#' `fa-width-auto` class.
#' @param dir String. Optional Web Awesome attribute.
#' @param family String. The family of icons to choose from. For Font
#' Awesome Free, valid options include `classic` and `brands`. For Font
#' Awesome Pro subscribers, valid options include, `classic`, `sharp`,
#' `duotone`, `sharp-duotone`, and `brands`. A valid kit code must be
#' present to show pro icons via CDN. You can set `<html
#' data-fa-kit-code="...">` to provide one.
#' @param flip Enumerated string. Allowed values: `both`, `x`, `y`. Sets
#' the flip direction of the icon along the 'x' (horizontal), 'y'
#' (vertical), or 'both' axes.
#' @param lang String. Optional Web Awesome attribute.
#' @param library String. Default: `default`. The name of a registered
#' custom icon library.
#' @param rotate Number. Default: `0`. Sets the rotation degree of the
#' icon
#' @param src String. An external URL of an SVG file. Be sure you trust
#' the content you are including, as it will be executed as code and can
#' result in XSS attacks.
#' @param swap_opacity Boolean. Default: `FALSE`. Swaps the opacity of
#' duotone icons.
#' @param variant String. The name of the icon's variant. For Font
#' Awesome, valid options include `thin`, `light`, `regular`, and `solid`
#' for the `classic` and `sharp` families. Some variants require a Font
#' Awesome Pro subscription. Custom icon libraries may or may not use this
#' property.
#'
#' @section Shiny Bindings:
#' None.
#'
#' @return An HTML tag for the component.
#'
#' @export
wa_icon <- function(
  ...,
  id = NULL,
  class = NULL,
  style = NULL,
  label = NULL,
  name = NULL,
  animation = NULL,
  auto_width = NULL,
  dir = NULL,
  family = NULL,
  flip = NULL,
  lang = NULL,
  library = NULL,
  rotate = NULL,
  src = NULL,
  swap_opacity = NULL,
  variant = NULL
) {
  children <- list(...)

  if (!is.null(animation)) {
    animation <- .wa_match_arg(
      animation,
      "animation",
      c(
        "beat",
        "beat-fade",
        "bounce",
        "fade",
        "flip",
        "shake",
        "spin",
        "spin-pulse",
        "spin-reverse"
      )
    )
  }

  if (!is.null(flip)) {
    flip <- .wa_match_arg(
      flip,
      "flip",
      c(
        "both",
        "x",
        "y"
      )
    )
  }

  attrs <- .wa_normalize_attrs(
    list(
      "id" = id,
      "class" = class,
      "style" = style,
      "label" = label,
      "name" = name,
      "animation" = animation,
      "auto-width" = auto_width,
      "dir" = dir,
      "family" = family,
      "flip" = flip,
      "lang" = lang,
      "library" = library,
      "rotate" = rotate,
      "src" = src,
      "swap-opacity" = swap_opacity,
      "variant" = variant
    ),
    boolean_names = c("auto-width", "swap-opacity"),
    boolean_arg_names = c(
      "auto-width" = "auto_width",
      "swap-opacity" = "swap_opacity"
    )
  )

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