Bootstrap / Bootstrap Icons and SVGs

Customizing Icon Sizes and Colors

This tutorial walks you through how to customize the size and color of Bootstrap Icons using CSS. We'll also explore how to ensure that your customizations align with your website…

Tutorial 3 of 5 5 resources in this section

Section overview

5 resources

Introduces Bootstrap Icons and SVGs for adding visual elements.

Introduction

This tutorial aims to guide you in customizing the size and color of Bootstrap Icons using CSS. Bootstrap icons are SVGs, so they can be styled with CSS, including size and color. By the end of this tutorial, you will be able to alter these properties to better match your website's design and aesthetics.

No prior knowledge is required, but a basic understanding of HTML, CSS, and Bootstrap could be beneficial.

Step-by-Step Guide

  • Size: Bootstrap icons' size can be adjusted using CSS properties like width and height. Using the font-size property will also scale the icon because they are SVGs.

  • Color: The fill property is used to change the color of Bootstrap icons. Setting this property will change the icon color.

  • Best Practices: Always aim for consistency in your website's design. When changing icon sizes and colors, ensure that they align with your site's overall aesthetic.

Code Examples

Here's an example of how you can customize your Bootstrap icons:

HTML:

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

CSS:

.bi-alarm-fill {
   width: 50px;
   height: 50px;
   fill: red;
}

In this example, we first select the icon using its class, then we set width and height to 50px and fill to red. This will make the icon larger and change its color to red.

Summary

In this tutorial, we've learned how to customize the size and color of Bootstrap Icons using CSS. You now know how to use the width, height, and fill properties to alter the size and color of these icons.

The next step would be to learn more about CSS and Bootstrap, such as how to use Bootstrap's built-in classes to further style your website. You can refer to the official Bootstrap documentation for more information.

Practice Exercises

  1. Exercise 1: Customize the size of the bi-check icon to 40px by 40px and change its color to green.

    • Solution:
      css .bi-check { width: 40px; height: 40px; fill: green; }
      This solution selects the bi-check icon and sets the width and height to 40px and fill to green.
  2. Exercise 2: Increase the size of the bi-x-circle-fill icon to 60px by 60px and change its color to red.

    • Solution:
      css .bi-x-circle-fill { width: 60px; height: 60px; fill: red; }
      This solution selects the bi-x-circle-fill icon and sets the width and height to 60px and fill to red.

For more practice, try to customize different Bootstrap icons and play around with the width, height, and fill properties.

Need Help Implementing This?

We build custom systems, plugins, and scalable infrastructure.

Discuss Your Project

Related topics

Keep learning with adjacent tracks.

View category

HTML

Learn the fundamental building blocks of the web using HTML.

Explore

CSS

Master CSS to style and format web pages effectively.

Explore

JavaScript

Learn JavaScript to add interactivity and dynamic behavior to web pages.

Explore

Python

Explore Python for web development, data analysis, and automation.

Explore

SQL

Learn SQL to manage and query relational databases.

Explore

PHP

Master PHP to build dynamic and secure web applications.

Explore

Popular tools

Helpful utilities for quick tasks.

Browse tools

Image Converter

Convert between different image formats.

Use tool

Case Converter

Convert text to uppercase, lowercase, sentence case, or title case.

Use tool

EXIF Data Viewer/Remover

View and remove metadata from image files.

Use tool

JavaScript Minifier & Beautifier

Minify or beautify JavaScript code.

Use tool

Timestamp Converter

Convert timestamps to human-readable dates.

Use tool

Latest articles

Fresh insights from the CodiWiki team.

Visit blog

AI in Drug Discovery: Accelerating Medical Breakthroughs

In the rapidly evolving landscape of healthcare and pharmaceuticals, Artificial Intelligence (AI) in drug dis…

Read article

AI in Retail: Personalized Shopping and Inventory Management

In the rapidly evolving retail landscape, the integration of Artificial Intelligence (AI) is revolutionizing …

Read article

AI in Public Safety: Predictive Policing and Crime Prevention

In the realm of public safety, the integration of Artificial Intelligence (AI) stands as a beacon of innovati…

Read article

AI in Mental Health: Assisting with Therapy and Diagnostics

In the realm of mental health, the integration of Artificial Intelligence (AI) stands as a beacon of hope and…

Read article

AI in Legal Compliance: Ensuring Regulatory Adherence

In an era where technology continually reshapes the boundaries of industries, Artificial Intelligence (AI) in…

Read article

Need help implementing this?

Get senior engineering support to ship it cleanly and on time.

Get Implementation Help