R/wa_avatar.R

Defines functions wa_avatar

Documented in wa_avatar

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

#' Create a `wa-avatar` component
#'
#' Generated wrapper for the Web Awesome `wa-avatar` 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: `""`. A label to use to describe the
#' avatar to assistive devices.
#' @param dir String. Optional Web Awesome attribute.
#' @param image String. Default: `""`. The image source to use for the
#' avatar.
#' @param initials String. Default: `""`. Initials to use as a fallback
#' when no image is available (1-2 characters max recommended).
#' @param lang String. Optional Web Awesome attribute.
#' @param loading Enumerated string. Allowed values: `eager`, `lazy`.
#' Default: `eager`. Indicates how the browser should load the image.
#' @param shape Enumerated string. Allowed values: `circle`, `rounded`,
#' `square`. Default: `circle`. The shape of the avatar.
#' @param icon The default icon to use when no image or initials are
#' present. Works best with `<wa-icon>`.
#'
#' @section Shiny Bindings:
#' None.
#'
#' @return An HTML tag for the component.
#'
#' @export
wa_avatar <- function(
  ...,
  id = NULL,
  class = NULL,
  style = NULL,
  label = NULL,
  dir = NULL,
  image = NULL,
  initials = NULL,
  lang = NULL,
  loading = NULL,
  shape = NULL,
  icon = NULL
) {
  children <- list(...)
  children <- c(
    children,
    list(
      .wa_slot(icon, "icon")
    )
  )

  if (!is.null(loading)) {
    loading <- .wa_match_arg(
      loading,
      "loading",
      c(
        "eager",
        "lazy"
      )
    )
  }

  if (!is.null(shape)) {
    shape <- .wa_match_arg(
      shape,
      "shape",
      c(
        "circle",
        "rounded",
        "square"
      )
    )
  }

  attrs <- .wa_normalize_attrs(
    list(
      "id" = id,
      "class" = class,
      "style" = style,
      "label" = label,
      "dir" = dir,
      "image" = image,
      "initials" = initials,
      "lang" = lang,
      "loading" = loading,
      "shape" = shape
    ),
    boolean_names = character(),
    boolean_arg_names = NULL
  )

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