Tool Bar
Webriq logo



A slideshow component for cycling through elements, like a carousel. Nested carousels are not supported.


  // Indicators
  ol.carousel-indicators'#carousel-example-generic', data-slide-to='0')
    li(data-target='#carousel-example-generic', data-slide-to='1')
    li(data-target='#carousel-example-generic', data-slide-to='2')

  // Wrapper for slides
      img(src='...', alt='...')
        | ...
      img(src='...', alt='...')
        | ...
        | ...

  // Controls
  a.left.carousel-control(href='#carousel-example-generic', role='button', data-slide='prev')
    span.glyphicon.glyphicon-chevron-left(aria-hidden='true') Previous
  a.right.carousel-control(href='#carousel-example-generic', role='button', data-slide='next')
    span.glyphicon.glyphicon-chevron-right(aria-hidden='true') Next

<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
    <li data-target="#carousel-example-generic" data-slide-to="1"></li>
    <li data-target="#carousel-example-generic" data-slide-to="2"></li>

  <!-- Wrapper for slides -->
  <div class="carousel-inner" role="listbox">
    <div class="item active">
      <img src="..." alt="...">
      <div class="carousel-caption">
    <div class="item">
      <img src="..." alt="...">
      <div class="carousel-caption">

  <!-- Controls -->
  <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
    <span class="sr-only">Next</span>

Optional captions

Add captions to your slides easily with the .carousel-caption element within any .item. Place just about any optional HTML within there and it will be automatically aligned and formatted.

  img(src='...', alt='...')
    h3 ...
    p ...

<div class="item">
  <img src="..." alt="...">
  <div class="carousel-caption">


Multiple carousels

Carousels require the use of an id on the outermost container (the .carousel) for carousel controls to function properly. When adding multiple carousels, or when changing a carousel's id, be sure to update the relevant controls.

Via data attributes

Use data attributes to easily control the position of the carousel. data-slide accepts the keywords prev or next, which alters the slide position relative to its current position. Alternatively, use data-slide-to to pass a raw slide index to the carousel data-slide-to="2", which shifts the slide position to a particular index beginning with 0.

The data-ride="carousel" attribute is used to mark a carousel as animating starting at page load. It cannot be used in combination with (redundant and unnecessary) explicit JavaScript initialization of the same carousel.

Via JavaScript

Call carousel manually with:



Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-interval="".

Name type default description
interval number 5000 The amount of time to delay between automatically cycling an item. If false, carousel will not automatically cycle.
pause string | null "hover" If set to "hover", pauses the cycling of the carousel on mouseenter and resumes the cycling of the carousel on mouseleave. If set to null, hovering over the carousel won't pause it.
wrap boolean true Whether the carousel should cycle continuously or have hard stops.
keyboard boolean true Whether the carousel should react to keyboard events.



Initializes the carousel with an optional options object and starts cycling through items.

  interval: 2000


Cycles through the carousel items from left to right.


Stops the carousel from cycling through items.


Cycles the carousel to a particular frame (0 based, similar to an array).


Cycles to the previous item.


Cycles to the next item.


Bootstrap's carousel class exposes two events for hooking into carousel functionality.

Both events have the following additional properties:

  • direction: The direction in which the carousel is sliding (either "left" or "right").
  • relatedTarget: The DOM element that is being slid into place as the active item.

All carousel events are fired at the carousel itself (i.e. at the <div class="carousel">).

Event Type Description This event fires immediately when the slide instance method is invoked. This event is fired when the carousel has completed its slide transition.

$('#myCarousel').on('', function () {
  // do something…