Skip to contents

A scroll-snap carousel. When inputId is set, input$<inputId> is the current slide index (1-based).

Usage

shad_carousel(
  inputId = NULL,
  ...,
  show_dots = TRUE,
  show_arrows = TRUE,
  class = NULL
)

shad_carousel_item(...)

Arguments

inputId

Optional input id (binds the current slide when set).

...

One or more shad_carousel_item().

show_dots

If TRUE (default), render the dot indicators.

show_arrows

If TRUE (default), render the prev/next arrows.

class

Extra CSS classes.

Value

A carousel tag.

Examples

shad_carousel("c",
  shad_carousel_item("Slide 1"), shad_carousel_item("Slide 2"))
#> <div class="shad-carousel" data-shad="carousel" id="c" aria-label="Carousel">
#>   <div class="shad-carousel__viewport">
#>     <div class="shad-carousel__track">
#>       <div class="shad-carousel__slide">Slide 1</div>
#>       <div class="shad-carousel__slide">Slide 2</div>
#>     </div>
#>   </div>
#>   <button type="button" class="shad-carousel__prev" aria-label="Previous slide"><svg class="shad-icon shad-icon--directional" data-direction="back" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m12 19-7-7 7-7"/><path d="M19 12H5"/></svg></button>
#>   <button type="button" class="shad-carousel__next" aria-label="Next slide"><svg class="shad-icon shad-icon--directional" data-direction="forward" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg></button>
#>   <div class="shad-carousel__dots"></div>
#> </div>