R/wa_drawer.R

Defines functions wa_drawer

Documented in wa_drawer

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

#' Create a `wa-drawer` component
#'
#' Generated wrapper for the Web Awesome `wa-drawer` 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 label String. Default: `""`. The drawer's label as displayed in
#' the header. You should always include a relevant label, as it is
#' required for proper accessibility. If you need to display HTML, use the
#' `label` slot instead.
#' @param dir String. Optional Web Awesome attribute.
#' @param lang String. Optional Web Awesome attribute.
#' @param light_dismiss Boolean. Default: `TRUE`. When enabled, the drawer
#' will be closed when the user clicks outside of it.
#' @param open Boolean. Default: `FALSE`. Indicates whether or not the
#' drawer is open. Toggle this attribute to show and hide the drawer.
#' @param placement Enumerated string. Allowed values: `bottom`, `end`,
#' `start`, `top`. Default: `end`. The direction from which the drawer
#' will open.
#' @param with_footer Boolean. Default: `FALSE`. Only required for SSR.
#' Set to `TRUE` if you're slotting in a `footer` element so the
#' server-rendered markup includes the footer before the component
#' hydrates on the client.
#' @param without_header Boolean. Default: `FALSE`. Disables the header.
#' This will also remove the default close button.
#' @param footer The drawer's footer, usually one or more buttons
#' representing various options.
#' @param header_actions Optional actions to add to the header. Works best
#' with `<wa-button>`.
#' @param label_slot The drawer's label. Alternatively, you can use the
#' `label` 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_drawer <- function(
  input_id,
  ...,
  class = NULL,
  style = NULL,
  label = NULL,
  dir = NULL,
  lang = NULL,
  light_dismiss = NULL,
  open = NULL,
  placement = NULL,
  with_footer = NULL,
  without_header = NULL,
  footer = NULL,
  header_actions = NULL,
  label_slot = NULL
) {
  children <- list(...)
  children <- c(
    children,
    list(
      .wa_slot(footer, "footer")
    )
  )
  children <- c(
    children,
    list(
      .wa_slot(header_actions, "header-actions")
    )
  )
  children <- c(
    children,
    list(
      .wa_slot(label_slot, "label")
    )
  )

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

  attrs <- .wa_normalize_attrs(
    list(
      "id" = input_id,
      "class" = class,
      "style" = style,
      "label" = label,
      "dir" = dir,
      "lang" = lang,
      "light-dismiss" = light_dismiss,
      "open" = open,
      "placement" = placement,
      "with-footer" = with_footer,
      "without-header" = without_header
    ),
    boolean_names = c(
      "light-dismiss",
      "open",
      "with-footer",
      "without-header"
    ),
    boolean_arg_names = c(
      "light-dismiss" = "light_dismiss",
      "open" = "open",
      "with-footer" = "with_footer",
      "without-header" = "without_header"
    )
  )

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