R/wa_details.R

Defines functions wa_details

Documented in wa_details

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

#' Create a `wa-details` component
#'
#' Generated wrapper for the Web Awesome `wa-details` component. When used
#' as a Shiny input, `input$<input_id>` reflects the component's current
#' semantic `open` state. The Shiny value is returned as a logical 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 disabled Boolean. Default: `FALSE`. Disables the details so it
#' can't be toggled.
#' @param name String. Groups related details elements. When one opens,
#' others with the same name will close.
#' @param appearance Enumerated string. Allowed values: `filled`,
#' `filled-outlined`, `outlined`, `plain`. Default: `outlined`. The
#' element's visual appearance.
#' @param dir String. Optional Web Awesome attribute.
#' @param icon_placement Enumerated string. Allowed values: `end`,
#' `start`. Default: `end`. The location of the expand/collapse icon.
#' @param lang String. Optional Web Awesome attribute.
#' @param open Boolean. Default: `FALSE`. Indicates whether or not the
#' details is open. You can toggle this attribute to show and hide the
#' details, or you can use the `show()` and `hide()` methods and this
#' attribute will reflect the details' open state.
#' @param summary String. The summary to show in the header. If you need
#' to display HTML, use the `summary` slot instead.
#' @param collapse_icon Optional collapse icon to use instead of the
#' default. Works best with `<wa-icon>`.
#' @param expand_icon Optional expand icon to use instead of the default.
#' Works best with `<wa-icon>`.
#' @param summary_slot The details' summary. Alternatively, you can use
#' the `summary` attribute.
#'
#' @section Shiny Bindings:
#' `input$<input_id>` reflects the component's current semantic `open`
#' state. The Shiny value is returned as a logical value.
#'
#' @return An HTML tag for the component.
#'
#' @export
wa_details <- function(
  input_id,
  ...,
  class = NULL,
  style = NULL,
  disabled = NULL,
  name = NULL,
  appearance = NULL,
  dir = NULL,
  icon_placement = NULL,
  lang = NULL,
  open = NULL,
  summary = NULL,
  collapse_icon = NULL,
  expand_icon = NULL,
  summary_slot = NULL
) {
  children <- list(...)
  children <- c(
    children,
    list(
      .wa_slot(collapse_icon, "collapse-icon")
    )
  )
  children <- c(
    children,
    list(
      .wa_slot(expand_icon, "expand-icon")
    )
  )
  children <- c(
    children,
    list(
      .wa_slot(summary_slot, "summary")
    )
  )

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

  if (!is.null(icon_placement)) {
    icon_placement <- .wa_match_arg(
      icon_placement,
      "icon_placement",
      c(
        "end",
        "start"
      )
    )
  }

  attrs <- .wa_normalize_attrs(
    list(
      "id" = input_id,
      "class" = class,
      "style" = style,
      "disabled" = disabled,
      "name" = name,
      "appearance" = appearance,
      "dir" = dir,
      "icon-placement" = icon_placement,
      "lang" = lang,
      "open" = open,
      "summary" = summary
    ),
    boolean_names = c("disabled", "open"),
    boolean_arg_names = c(
      "disabled" = "disabled",
      "open" = "open"
    )
  )

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