mstdmstd's avatar

How to change font/background color of svg icons ?

In laravel 10 / Bootstrap 5 app I need to change font/background color of svg icons.

Searching in net I found that it is not easy / impossible at all... Are there some other similar collections of icons in which that is easily to change font/background color of svg icons ?

0 likes
2 replies
RemiM's avatar

Since your project uses Bootstrap, you can enhance it by including the Bootstrap Icons library. To customize the icon colors, use the provided sprite and apply a .text-* class or custom CSS for color styling. For example:

<svg class="bi bi-exclamation-triangle text-success" width="32" height="32" fill="currentColor" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
  ...
</svg>

This approach allows you to easily adjust the icon's appearance while keeping your design consistent with Bootstrap's styling conventions.

Or, you can follow the solution proposed by @snapey and modify the fill and stroke attributes directly.

Please or to participate in this conversation.