How to Change Button Color in Bootstrap 5 ?
Last Updated :
28 Apr, 2025
Bootstrap 5 provides developers with a lot of capabilities that enable them to create responsive and aesthetically pleasing online apps. Developers frequently require customizations, such as altering button colors to better reflect their branding or design philosophies. This post will walk you through the process of altering the button colors in Bootstrap 5 step-by-step.
Using predefined color classes
A range of pre-styled buttons are available with Bootstrap and may be readily altered. With Bootstrap, buttons are made with the <button>` element, and preset classes may be used to change the color and look. To change the colors of the button, you can define custom styles or use one of the predefined color classes to alter the color of a Bootstrap button. There are several pre-defined color classes in Bootstrap like btn-primary, btn-secondary, btn-success etc.
Syntax:
<button type="button" class="btn btn-primary">Primary Button</button>
Example: To demonstrate changing the color of the button using the predefined bootstrap classes.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<link href=
"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet" />
<script src=
"https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js">
</script>
</head>
<body>
<div class="container text-center">
<div class="mt-1">
<h2 class="text-success">GeeksforGeeks</h2>
<h2>Different colors of buttons in Bootstrap 5</h2>
</div>
<div class="mt-3">
<button type="button" class="btn btn-primary">
Monochromatic Blue
</button>
<button type="button" class="btn btn-secondary">
Grey
</button>
<button type="button" class="btn btn-success">
Green
</button>
<button type="button" class="btn btn-danger">
Red
</button>
<button type="button" class="btn btn-warning">
Yellow
</button>
<button type="button" class="btn btn-info">
Sky Blue
</button>
<button type="button" class="btn btn-light">
Off White
</button>
<button type="button" class="btn btn-dark">
Monochromatic Black
</button>
</div>
</div>
</body>
</html>
Output:
There are different type of button in BootstrapUsing custom CSS styles
User can also customize the color, by adding hard coded CSS styles according to there own needs and requirements.
Example: To demonstrate changing the color of the button using custom CSS styles.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<link href=
"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet" />
<script src=
"https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js">
</script>
<style>
.custom-btn {
background-color: #8b0000;
color: #fff;
}
</style>
</head>
<body>
<div class="container text-center">
<div class="mt-1">
<h2 class="text-success">GeeksforGeeks</h2>
<h2>Custom color of button in Bootstrap 5</h2>
</div>
<div class="mt-3">
<button type="button" class="btn custom-btn">
Custom Button
</button>
</div>
</div>
</body>
</html>
Output:
Custom colour in Bootstrap 5
Similar Reads
How to Change Close Button Color in Bootstrap 5? Changing the color of the close button in Bootstrap 5 involves customizing the styles using CSS. The close button in Bootstrap 5 has a specific class .btn-close, and you can override its styles to achieve the desired color. In this article, we will see how we can do it.Preview PrerequisitesHTMLCSS B
2 min read
How to Change Colors for a Button in React-Bootstrap? In this tutorial, we will learn how to change the colors of buttons in React-Bootstrap. The Button component in React-Bootstrap is a simple button with CSS and the effects of Boostrap. We can apply different colors based on the different situations like Error, Success, etc. Steps to create the appli
2 min read
How to get circular buttons in bootstrap 4 ? It is an open source toolkit for developing with the HTML, CSS, and JS. It includes several types of buttons, styles, fonts each of them serving its own semantic purpose which is predefined, with a few extras thrown for more control. You can use Bootstrap custom button styles to create your buttons
2 min read
How to Create "Add to cart" Button in Bootstrap? Creating an "Add to Cart" button in Bootstrap is simple and helps improve the shopping experience on your website. Bootstrap has ready-made styles that make it easy to create buttons that look good and work well on all devices.Approach to creating an "Add to cart" Button in BootstrapUse a Bootstrap
2 min read
How to Change Accordion Button Collapsed Icon Color in Bootstrap ? This article demonstrates how to customize the colors of the accordion button icons in a Bootstrap accordion. By default, Bootstrap accordions use a plus/minus arrow icon to indicate the collapsed or expanded state of accordion items. This tutorial provides step-by-step instructions on how to change
3 min read