Carousel (original) (raw)
A carousel can be useful to cycle through slides with related content. There like the accordion, there are two main functions:
[bs_carousel()](../reference/bs%5Fcarousel.html)
, used to establish the carousel framework, with argumentsid
,use_indicators
, for the “dots” indicating the slide, anduse_controls
, for the directional controls at either side.[bs_append()](../reference/bs%5Fappend.html)
, used to add a slide containingcontent
, which is HTML, and an optionalcaption
.
The content
and caption
arguments can be composed using the helper functions [bs_carousel_image()](../reference/bs%5Fcarousel%5Fimage.html)
, which returs a centered-image tag, and[bs_carousel_caption()](../reference/bs%5Fcarousel%5Fcaption.html)
with text argumentstitle
and body
.
bs_carousel(id = "the_beatles", use_indicators = TRUE) %>%
bs_append(
content = bs_carousel_image(src = "img/john.jpg", alt = "John Lennon"),
caption = bs_carousel_caption("John Lennon", "Rhythm guitar, vocals")
) %>%
bs_append(
content = bs_carousel_image(src = "img/paul.jpg", alt = "Paul McCartney"),
caption = bs_carousel_caption("Paul McCartney", "Bass guitar, vocals")
) %>%
bs_append(
content = bs_carousel_image(src = "img/george.jpg", alt = "George Harrison"),
caption = bs_carousel_caption("George Harrison", "Lead guitar, vocals")
) %>%
bs_append(
content = bs_carousel_image(src = "img/ringo.jpg", alt = "Ringo Starr"),
caption = bs_carousel_caption("Ringo Starr", "Drums, vocals")
)
John Lennon
Rhythm guitar, vocals
Paul McCartney
Bass guitar, vocals
George Harrison
Lead guitar, vocals
Ringo Starr
Drums, vocals
Here’s another rendering of the carousel, this time:
- without indicators
- without captions
- the slides do not auto-advance (using
[bs_set_data()](../reference/bs%5Fset%5Fdata.html)
to set Bootstrap options)