Master Bootstrap From Scratch

Clear, interactive, and structured Bootstrap lessons designed for beginners and developers.

Bootstrap Icons

Bootstrap Icons are a collection of ready-to-use icons that can be used in buttons, navigation menus, forms, alerts, cards and many other parts of a website.

Simple Explanation: Icons are small visual symbols used to communicate an action or meaning quickly. For example, a search icon can represent Search and a trash icon can represent Delete.

1. What are Bootstrap Icons?

Bootstrap Icons is an icon library designed to work with Bootstrap and other web projects.

Icons can make a website easier to understand because users can quickly recognize common actions and features.

Simple Explanation: Instead of writing only "Search", we can display a search icon along with the text. This makes the interface more visual and user-friendly.

2. Installing Bootstrap Icons

Before using Bootstrap Icons, the Bootstrap Icons stylesheet needs to be included in the project.

CDN Example

<link rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
Simple Explanation: The CDN link loads the Bootstrap Icons CSS file, which allows us to use Bootstrap icon classes inside our HTML.

3. Basic Icon

Bootstrap Icons are normally created using an <i> element with the bi class and the required icon class.

Example

<i class="bi bi-alarm"></i>

<i class="bi bi-house"></i>

<i class="bi bi-search"></i>
Output:

4. Commonly Used Icons

Bootstrap Icons provides icons for many common actions and interface elements.

Simple Explanation: Common icons such as Home, Search, User, Settings, Delete and Download can be used to make website controls easier to understand.

Example

<i class="bi bi-house"></i>

<i class="bi bi-person"></i>

<i class="bi bi-gear"></i>

<i class="bi bi-trash"></i>

<i class="bi bi-download"></i>
Output:

5. Changing Icon Size

Bootstrap Icons can be resized using Bootstrap font-size utility classes or custom CSS.

Simple Explanation: An icon can be made small, medium or large depending on where it is being used.

Example

<i class="bi bi-star fs-1"></i>

<i class="bi bi-star fs-2"></i>

<i class="bi bi-star fs-3"></i>
Output:

6. Icons with Buttons

Icons can be placed inside Bootstrap buttons to make the purpose of the button clearer.

Simple Explanation: An icon can be combined with button text. For example, a download icon can be displayed inside a Download button.

Example

<button class="btn btn-primary">

    <i class="bi bi-download"></i>
    Download

</button>
Output:

7. Icons with Text

Icons can be placed before or after text to provide additional visual meaning.

Simple Explanation: The icon gives the user a quick visual idea about what the text represents.

Example

<p>
    <i class="bi bi-envelope"></i>
    Email Us
</p>

<p>
    <i class="bi bi-telephone"></i>
    Contact Us
</p>
Output:

Email Us

Contact Us

8. Icons in Navigation

Icons can be used inside navigation links to make navigation items easier to recognize.

Simple Explanation: A Home icon can be displayed beside Home, a Book icon beside Courses and a Person icon beside Profile.

Example

<nav>

    <a href="#" class="me-4">
        <i class="bi bi-house"></i>
        Home
    </a>

    <a href="#" class="me-4">
        <i class="bi bi-book"></i>
        Courses
    </a>

    <a href="#">
        <i class="bi bi-person"></i>
        Profile
    </a>

</nav>
Output:

9. Icons in Alerts

Icons can make alert messages easier to understand.

Simple Explanation: A check icon can indicate success, while an exclamation icon can indicate a warning.

Example

<div class="alert alert-success">

    <i class="bi bi-check-circle"></i>

    Registration completed successfully.

</div>
Registration completed successfully.

10. Icons in Forms

Icons can be used alongside form labels to provide additional visual meaning.

Simple Explanation: A person icon can be used for a username field, while an envelope icon can be used for an email field.

Example

<label class="form-label">

    <i class="bi bi-person"></i>

    Name

</label>

<input type="text"
       class="form-control"
       placeholder="Enter your name">

11. Icons with Lists

Icons can be used inside lists to visually represent each item.

Simple Explanation: Instead of using plain bullet points, we can use meaningful icons for each list item.

Example

<ul class="list-unstyled">

    <li>
        <i class="bi bi-check-circle"></i>
        Live Project
    </li>

    <li>
        <i class="bi bi-check-circle"></i>
        Internship
    </li>

    <li>
        <i class="bi bi-check-circle"></i>
        Interview Preparation
    </li>

</ul>
  • Live Project
  • Internship
  • Interview Preparation

12. Real-World CIIT Training Institute Example

Bootstrap Icons can be used on a training institute website to represent courses, contact information, learning features and actions.

Simple Explanation: Icons can make course information easier to scan. For example, a book icon can represent a course, a clock icon can represent duration and a phone icon can represent contact information.

Example

<div>

    <p>
        <i class="bi bi-book"></i>
        Full Stack Development
    </p>

    <p>
        <i class="bi bi-clock"></i>
        Duration: 6 Months
    </p>

    <p>
        <i class="bi bi-telephone"></i>
        Contact CIIT Training Institute
    </p>

    <button class="btn btn-primary">

        <i class="bi bi-arrow-right"></i>

        Learn More

    </button>

</div>
Output:

Full Stack Development

Duration: 6 Months

Contact CIIT Training Institute

Important Bootstrap Icon Classes

Class Purpose
.bi Base Bootstrap Icons class.
.bi-house Displays a home icon.
.bi-search Displays a search icon.
.bi-person Displays a person icon.
.bi-gear Displays a settings icon.
.bi-trash Displays a delete/trash icon.
.bi-download Displays a download icon.
.bi-check-circle Displays a check-circle icon.
.bi-arrow-right Displays a right-arrow icon.
.fs-1 Bootstrap utility for larger font size.

Common Mistakes

  • Forgetting to include the Bootstrap Icons stylesheet.
  • Using an incorrect icon class name.
  • Forgetting the base bi class.
  • Using too many icons and making the interface difficult to understand.
  • Using icons without considering their meaning.
  • Using icons without sufficient spacing from nearby text.

Summary

  • Bootstrap Icons provide ready-to-use visual symbols.
  • The bi class is used as the base icon class.
  • Specific classes such as bi-house and bi-search select the required icon.
  • Icons can be used with buttons, navigation, forms, alerts and lists.
  • Bootstrap font-size utilities can be used to control icon size.
  • Icons should be used meaningfully so that they improve the user interface.