R/wa_carousel.R

Defines functions wa_carousel

Documented in wa_carousel

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

#' Create a `wa-carousel` component
#'
#' Generated wrapper for the Web Awesome `wa-carousel` component. When
#' used as a Shiny input, `input$<input_id>` reflects the component's
#' current semantic `activeSlide` state. The Shiny value is returned as a
#' numeric value. This index is 0-based.
#' 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 autoplay Boolean. Default: `FALSE`. When set, the slides will
#' scroll automatically when the user is not interacting with them.
#' @param autoplay_interval Number. Default: `3000`. Specifies the amount
#' of time, in milliseconds, between each automatic scroll.
#' @param current_slide Number. Default: `0`. Optional Web Awesome
#' attribute.
#' @param dir String. Optional Web Awesome attribute.
#' @param lang String. Optional Web Awesome attribute.
#' @param loop Boolean. Default: `FALSE`. When set, allows the user to
#' navigate the carousel in the same direction indefinitely.
#' @param mouse_dragging Boolean. Default: `FALSE`. When set, it is
#' possible to scroll through the slides by dragging them with the mouse.
#' @param navigation Boolean. Default: `FALSE`. When set, show the
#' carousel's navigation.
#' @param orientation Enumerated string. Allowed values: `horizontal`,
#' `vertical`. Default: `horizontal`. Specifies the orientation in which
#' the carousel will lay out.
#' @param pagination Boolean. Default: `FALSE`. When set, show the
#' carousel's pagination indicators.
#' @param slides Number. Default: `0`. Optional Web Awesome attribute.
#' @param slides_per_move Number. Default: `1`. Specifies the number of
#' slides the carousel will advance when scrolling, useful when specifying
#' a `slides-per-page` greater than one. It can't be higher than
#' `slides-per-page`.
#' @param slides_per_page Number. Default: `1`. Specifies how many slides
#' should be shown at a given time.
#' @param next_icon Optional next icon to use instead of the default.
#' Works best with `<wa-icon>`.
#' @param previous_icon Optional previous icon to use instead of the
#' default. Works best with `<wa-icon>`.
#'
#' @section Shiny Bindings:
#' `input$<input_id>` reflects the component's current semantic
#' `activeSlide` state. The Shiny value is returned as a numeric value.
#' This index is 0-based.
#'
#' @return An HTML tag for the component.
#'
#' @export
wa_carousel <- function(
  input_id,
  ...,
  class = NULL,
  style = NULL,
  autoplay = NULL,
  autoplay_interval = NULL,
  current_slide = NULL,
  dir = NULL,
  lang = NULL,
  loop = NULL,
  mouse_dragging = NULL,
  navigation = NULL,
  orientation = NULL,
  pagination = NULL,
  slides = NULL,
  slides_per_move = NULL,
  slides_per_page = NULL,
  next_icon = NULL,
  previous_icon = NULL
) {
  children <- list(...)
  children <- c(
    children,
    list(
      .wa_slot(next_icon, "next-icon")
    )
  )
  children <- c(
    children,
    list(
      .wa_slot(previous_icon, "previous-icon")
    )
  )

  if (!is.null(orientation)) {
    orientation <- .wa_match_arg(
      orientation,
      "orientation",
      c(
        "horizontal",
        "vertical"
      )
    )
  }

  attrs <- .wa_normalize_attrs(
    list(
      "id" = input_id,
      "class" = class,
      "style" = style,
      "autoplay" = autoplay,
      "autoplay-interval" = autoplay_interval,
      "currentSlide" = current_slide,
      "dir" = dir,
      "lang" = lang,
      "loop" = loop,
      "mouse-dragging" = mouse_dragging,
      "navigation" = navigation,
      "orientation" = orientation,
      "pagination" = pagination,
      "slides" = slides,
      "slides-per-move" = slides_per_move,
      "slides-per-page" = slides_per_page
    ),
    boolean_names = c(
      "autoplay",
      "loop",
      "mouse-dragging",
      "navigation",
      "pagination"
    ),
    boolean_arg_names = c(
      "autoplay" = "autoplay",
      "loop" = "loop",
      "mouse-dragging" = "mouse_dragging",
      "navigation" = "navigation",
      "pagination" = "pagination"
    )
  )

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