R/wa_copy_button.R

Defines functions wa_copy_button

Documented in wa_copy_button

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

#' Create a `wa-copy-button` component
#'
#' Generated wrapper for the Web Awesome `wa-copy-button` 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 value String. Default: `""`. The text value to copy.
#' @param disabled Boolean. Default: `FALSE`. Disables the copy button.
#' @param copy_label String. Default: `""`. A custom label to show in the
#' tooltip.
#' @param dir String. Optional Web Awesome attribute.
#' @param error_label String. Default: `""`. A custom label to show in the
#' tooltip when a copy error occurs.
#' @param feedback_duration Number. Default: `1000`. The length of time to
#' show feedback before restoring the default trigger.
#' @param from String. Default: `""`. An id that references an element in
#' the same document from which data will be copied. If both this and
#' `value` are present, this value will take precedence. By default, the
#' target element's `textContent` will be copied. To copy an attribute,
#' append the attribute name wrapped in square brackets, e.g.
#' `from="elvalue"`. To copy a property, append a dot and the property
#' name, e.g. `from="el.value"`.
#' @param lang String. Optional Web Awesome attribute.
#' @param success_label String. Default: `""`. A custom label to show in
#' the tooltip after copying.
#' @param tooltip_placement Enumerated string. Allowed values: `bottom`,
#' `left`, `right`, `top`. Default: `top`. The preferred placement of the
#' tooltip.
#' @param copy_icon The icon to show in the default copy state. Works best
#' with `<wa-icon>`.
#' @param error_icon The icon to show when a copy error occurs. Works best
#' with `<wa-icon>`.
#' @param success_icon The icon to show when the content is copied. Works
#' best with `<wa-icon>`.
#'
#' @section Shiny Bindings:
#' None.
#'
#' @return An HTML tag for the component.
#'
#' @export
wa_copy_button <- function(
  ...,
  id = NULL,
  class = NULL,
  style = NULL,
  value = NULL,
  disabled = NULL,
  copy_label = NULL,
  dir = NULL,
  error_label = NULL,
  feedback_duration = NULL,
  from = NULL,
  lang = NULL,
  success_label = NULL,
  tooltip_placement = NULL,
  copy_icon = NULL,
  error_icon = NULL,
  success_icon = NULL
) {
  children <- list(...)
  children <- c(
    children,
    list(
      .wa_slot(copy_icon, "copy-icon")
    )
  )
  children <- c(
    children,
    list(
      .wa_slot(error_icon, "error-icon")
    )
  )
  children <- c(
    children,
    list(
      .wa_slot(success_icon, "success-icon")
    )
  )

  if (!is.null(tooltip_placement)) {
    tooltip_placement <- .wa_match_arg(
      tooltip_placement,
      "tooltip_placement",
      c(
        "bottom",
        "left",
        "right",
        "top"
      )
    )
  }

  attrs <- .wa_normalize_attrs(
    list(
      "id" = id,
      "class" = class,
      "style" = style,
      "value" = value,
      "disabled" = disabled,
      "copy-label" = copy_label,
      "dir" = dir,
      "error-label" = error_label,
      "feedback-duration" = feedback_duration,
      "from" = from,
      "lang" = lang,
      "success-label" = success_label,
      "tooltip-placement" = tooltip_placement
    ),
    boolean_names = c("disabled"),
    boolean_arg_names = c("disabled" = "disabled")
  )

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