Ask any question about Bootstrap here... and get an instant response.
Post this Question & Answer:
How can I customize the default Bootstrap button colors without overriding the core styles?
Asked on Feb 04, 2026
Answer
To customize Bootstrap button colors without overriding the core styles, you can use Bootstrap's CSS variables. This allows you to change button colors while still adhering to Bootstrap's design system.
<!-- BEGIN COPY / PASTE -->
<style>
:root {
--bs-btn-bg: #4CAF50; /* Custom background color */
--bs-btn-border-color: #4CAF50; /* Custom border color */
--bs-btn-hover-bg: #45a049; /* Custom hover background color */
--bs-btn-hover-border-color: #45a049; /* Custom hover border color */
}
</style>
<button class="btn btn-primary">Custom Button</button>
<!-- END COPY / PASTE -->Additional Comment:
✅ Answered with Bootstrap 5 best practices.- You can customize button colors by defining CSS variables in the `:root` selector.
- The `--bs-btn-bg` and `--bs-btn-border-color` variables set the default background and border colors.
- The `--bs-btn-hover-bg` and `--bs-btn-hover-border-color` variables set the hover state colors.
- This approach ensures you are not directly overriding Bootstrap's core styles but extending them with custom values.
Recommended Links:
