<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: swckd</title>
    <description>The latest articles on DEV Community by swckd (@swckd).</description>
    <link>https://dev.to/swckd</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1283059%2Fac25cebf-fdea-4f4f-9635-b81664c51be5.jpg</url>
      <title>DEV Community: swckd</title>
      <link>https://dev.to/swckd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/swckd"/>
    <language>en</language>
    <item>
      <title>Bootstrap 5 Carousel with thumbnails as navigator indicators</title>
      <dc:creator>swckd</dc:creator>
      <pubDate>Mon, 26 Feb 2024 12:23:51 +0000</pubDate>
      <link>https://dev.to/swckd/bootstrap-5-carousel-with-thumbnails-as-navigator-indicators-g7k</link>
      <guid>https://dev.to/swckd/bootstrap-5-carousel-with-thumbnails-as-navigator-indicators-g7k</guid>
      <description>&lt;p&gt;In this post I'll show you how to include thumbnails pictures as &lt;a href="https://getbootstrap.com/docs/5.3/components/carousel/"&gt;Bootstrap 5 Carousel navigators indicators&lt;/a&gt;:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5yhrhit1bc7kmuej4u43.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5yhrhit1bc7kmuej4u43.gif" alt="Image description" width="717" height="789"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, start by creating the Carousel following Bootstrap´s documentation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;div id="myCarousel" class="carousel slide" data-bs-ride="carousel"&amp;gt;
      &amp;lt;div class="carousel-inner"&amp;gt;
        &amp;lt;div class="carousel-item active"&amp;gt;
          &amp;lt;img
            data-bs-toggle="modal"
            data-bs-target="#myModal"
            src="http://via.placeholder.com/640x360/blue"
            class="d-block w-100 rounded"
          /&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class="carousel-item"&amp;gt;
          &amp;lt;img
            data-bs-toggle="modal"
            data-bs-target="#myModal"
            src="http://via.placeholder.com/640x360/pink"
            class="d-block w-100 rounded"
          /&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class="carousel-item"&amp;gt;
          &amp;lt;img
            data-bs-toggle="modal"
            data-bs-target="#myModal"
            src="http://via.placeholder.com/640x360/green"
            class="d-block w-100 rounded"
          /&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class="carousel-item"&amp;gt;
          &amp;lt;img
            data-bs-toggle="modal"
            data-bs-target="#myModal"
            src="http://via.placeholder.com/640x360/yellow"
            class="d-block w-100 rounded"
          /&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this code, the Carousel starts with:&lt;br&gt;
&lt;code&gt;&amp;lt;div id="myCarousel" class="carousel slide" data-bs-ride="carousel"&amp;gt;&lt;/code&gt;&lt;br&gt;
And we need to create the section &lt;strong&gt;carousel-innner&lt;/strong&gt;, which holds the carousel items.&lt;br&gt;
&lt;code&gt;&amp;lt;div class="carousel-inner"&amp;gt;&lt;/code&gt;&lt;br&gt;
The carousel items must be composed of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        &amp;lt;div class="carousel-item"&amp;gt;
          &amp;lt;img
            src="http://via.placeholder.com/640x360/yellow"
            class="d-block w-100 rounded"
          /&amp;gt;
        &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, we create the indicators section, composed of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The holding div with &lt;strong&gt;carousel-indicators&lt;/strong&gt; class.
&lt;code&gt;&amp;lt;div class="carousel-indicators m-auto"&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;A button with data-bs-target, and data-bs-slide-to (starting from 0)&lt;/li&gt;
&lt;li&gt;The img of the thumnail
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        &amp;lt;button
          type="button"
          data-bs-target="#myCarousel"
          class="active thumbnail-indicator"
          data-bs-slide-to="0"
        &amp;gt;
          &amp;lt;img
            src="http://via.placeholder.com/80x80/blue"
            class="active d-block w-100 rounded"
          /&amp;gt;
        &amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the CSS will look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.carousel-indicators {
  position: unset !important;
}
.carousel-indicators [data-bs-target] {
  opacity: 1;
  background-color: transparent !important;
  width: 80px !important;
  height: 80px !important;
}

.thumbnail-indicator {
  position: relative;
  overflow: hidden;
}

.thumbnail-indicator img {
  width: 100%;
  height: auto;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the indicators, you can optionally add the arrows to move from one slide to the other:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      &amp;lt;button
        class="carousel-control-prev"
        type="button"
        data-bs-target="#myCarousel"
        data-bs-slide="prev"
      &amp;gt;
        &amp;lt;span class="carousel-control-prev-icon" aria-hidden="true"&amp;gt;&amp;lt;/span&amp;gt;
        &amp;lt;span class="visually-hidden"&amp;gt;Previous&amp;lt;/span&amp;gt;
      &amp;lt;/button&amp;gt;
      &amp;lt;button
        class="carousel-control-next"
        type="button"
        data-bs-target="#myCarousel"
        data-bs-slide="next"
      &amp;gt;
        &amp;lt;span class="carousel-control-next-icon" aria-hidden="true"&amp;gt;&amp;lt;/span&amp;gt;
        &amp;lt;span class="visually-hidden"&amp;gt;Next&amp;lt;/span&amp;gt;
      &amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The full code can be found here: &lt;a href="https://stackblitz.com/edit/stackblitz-starters-immwvx"&gt;https://stackblitz.com/edit/stackblitz-starters-immwvx&lt;/a&gt;&lt;/p&gt;

</description>
      <category>bootstrap5</category>
      <category>carousel</category>
      <category>thumbnails</category>
      <category>indicators</category>
    </item>
  </channel>
</rss>
