The button text in Bootstrap 5 is black instead of white as shown in their demo

During the installation of Bootstrap 5, I encountered an issue where many of my buttons are displaying a black font instead of the expected white font as shown in the Bootstrap 5 Documentation

For instance, the .btn-primary button on the official Bootstrap docs looks like this:

https://i.sstatic.net/eEII1.png

However, when utilizing the exact same HTML code, I end up with this result:

https://i.sstatic.net/KLe06.png

Upon examining both their example and mine, it seems that not only is the text color different, but the background color is also not consistent. Upon inspecting my compiled .css file, I noticed that several of the bootstrap colors used throughout the code appear "washed out," resembling the blue hue in the button. After using Chrome dev tools, it appears that this style is originating from the Bootstrap files themselves rather than any inadvertent styling I may have applied. The SCSS compiles down to CSS files through the standard Laravel setup (webpack mix), and I solely rely on NPM packages for bootstrap 5.

window.bootstrap = require('bootstrap');
alongside the NPM package
"bootstrap": "^5.1.3",

The content of my app.scss file is quite minimal:

// Fonts
@import url('https://fonts.googleapis.com/css?family=Nunito');

// Variables
@import 'variables';

// Bootstrap
@import '~bootstrap/scss/bootstrap';
@import "~bootstrap-icons/font/bootstrap-icons";

// "Lobster" Font for H1's
@import "https://fonts.googleapis.com/css2?family=Cuprum&family=Lobster&display=swap";

// Flatpickr Styles
@import "~flatpickr/dist/flatpickr.min.css";

// Font Awesome Free
@import "~@fortawesome/fontawesome-free/css/all.min.css";

// DataTables Styles
@import "~datatables.net-bs5/css/dataTables.bootstrap5.min.css";
@import "~datatables.net-responsive-bs5/css/responsive.bootstrap5.min.css";

h1 {
    font-family: 'Lobster', cursive;
}

a.torn-link {
    color: $orange;
}

.ttt-title {
    font-family: 'Lobster', cursive;
}
.card-title {
    font-family: 'Cuprum', sans-serif;
}
html {
    background-color: #fff;
    color: #636b6f;
}
body {
    background-color: #fff;
    color: #636b6f;
}
.links {
    >a {
        color: #636b6f;
        padding: 0 25px;
        font-size: 13px;
        font-weight: 600;
        letter-spacing: .1rem;
        text-decoration: none;
        text-transform: uppercase;
    }
}
#settings-button {
    &:hover {
        fill: rgba(189, 189, 189, 0.25);
    }
}
.ui-dialog-title {
    font-family: 'Cuprum', sans-serif;
}

thead, th {
    text-align: center;
}

Edit: It seems even the colored links specified by Bootstrap exhibit a washed-out appearance. For instance, the yellow from .link-warning is barely visible due to its faint color intensity, which undermines readability. In contrast, the yellow displayed on the official page is distinctively clear. Therefore, this issue does not stem from mistakenly applying styles to buttons or elements.

Edit2:

This showcases how my button appears within the developer tools, highlighting the disparity in colors compared to those in the Bootstrap 5 documentation.

https://i.sstatic.net/aqMif.png

Furthermore, the button's CSS property is solely derived from the compiled app.css file generated via webpack:

https://i.sstatic.net/q4Sls.png

Edit 3: Contents of my _variables.scss file:

// Body
$body-bg: #f8fafc;

// Typography
$font-family-sans-serif: 'Nunito', sans-serif;
$font-size-base: 0.9rem;
$line-height-base: 1.6;

// Colors
$blue: #3490dc;
$indigo: #6574cd;
$purple: #9561e2;
$pink: #f66d9b;
$red: #e3342f;
$orange: #f6993f;
$yellow: #ffed4a;
$green: #38c172;
$teal: #4dc0b5;
$cyan: #6cb2eb;

Answer №1

While incorporating Bootstrap 5 into Laravel 8, a modification was made to the _variables.scss file that introduced new color styles. Unfortunately, these colors were not in sync with the default Bootstrap palette and resulted in a washed out appearance for elements using those variables.

Upon further investigation, it was discovered that removing the additional color definitions from the _variables.scss file resolved the issue and restored the intended appearance of Bootstrap components.

Answer №2

Thank you ComputerLocus for your response, I was actually facing the same issue. Because of my reputation, I couldn't leave a comment so I am posting this as an answer.

The solution provided is accurate. To elaborate further, you will need to access _variables.scss located in resources/sass/. After removing the conflicting color declarations, run npm run dev in the terminal within your main project directory. If the changes are still not reflected, try refreshing your page using ctrl + F5.

That sums it up, folks :)

Answer №3

Bootstrap 5 now incorporates a special Color Contrast feature. This innovative function is utilized across Bootstrap to ensure that all components adhere to the color contrast accessibility standards outlined by WCAG. When you define a .btn-primary element, Bootstrap automatically applies the color contrast algorithm to evaluate the luminance of your specified $primary/$blue hex value. Upon assessment, if the contrast between the provided #3490dc and the default text color color: #FFFFFF is deemed insufficient, Bootstrap adjusts it to use color: #000000 instead.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having trouble getting the custom font to display correctly in xhtml2pdf for a Django project

I'm having trouble incorporating a custom font into my PDF generated from HTML. Although I successfully displayed the font in an HTML file, indicating that the font path is correct and it's being used properly, the .ttf font type doesn't re ...

What is the best way to ensure that every item on a list can be

Is there a way to make both the left and right sides of a list item clickable? Currently, only the right side is clickable in my case. Any suggestions? This is my HTML: <body> <aside id = "aside"> <div id="column"> ...

Please be aware that any fabricated comments will not be displayed in the posts object

-I have made an EDIT at the bottom of my original post -For my plunker, please visit this link Currently, I am learning AngularJS by following a tutorial located here. At this moment, I am stuck on the step called 'Faking comment data'. I have ...

Having trouble with the menu toggle button on Bootstrap 4?

When using Bootstrap 4, the breadcrumb button may not function properly when the header becomes responsive. I have ensured that Bootstrap 4 CSS and JS are included in the project. Please assist me in resolving this issue. Code: .navbar { height:100 ...

Is there a way to horizontally navigate a pallet using Next and Prev buttons?

As someone new to development, I am looking for a way to scroll my question pallet up and down based on the question number when I click next and previous buttons. In my pallet div, there are over 200 questions which are dynamically generated. However, th ...

Include parameters for a pagination system

I have a script that fetches data from my database and generates pagination. Everything is working fine, but now I want to include a conditional statement to differentiate the user level as New, Current, or Renewing client. I've already set up some s ...

Implementing the 'bootstrap tour' feature in a Ruby on Rails application

I have integrated bootstrap-tour.min.css and bootstrap-tour.min.js into my project. <script type="text/javascript" src='bootstrap-tour.min.js'></script> <link rel="stylesheet" type="text/css" href="bootstrap-tour.min.css"> Her ...

Ways to display an SVG spinner prior to a substantial UI refresh

I am currently facing an issue with updating 10 apexcharts bar charts simultaneously in a Vue app. When this process occurs, it takes approximately one second to load completely, and during that time, I would like to display an svg spinner. However, the co ...

Changing the boolean value of User.isActive in Node.js: A step-by-step guide

Define a User Model with isActive as a Boolean property. Upon clicking a button, the user is redirected to a route where their information is retrieved based on the id from the parameters. Once the user is found, the script checks the value of isActive. ...

Omit specific TagNames from the selection

How can I exclude <BR> elements when using the statement below? var children = document.getElementById('id').getElementsByTagName('*'); Is there a special syntax for getElementsByTagName that allows me to achieve this, or is the ...

Unable to retrieve a response, the operation `users.findOne()` has exceeded the buffering time limit of 10000ms

I encountered an issue when attempting to make a POST login request. The frontend is deployed on Netlify here, and the backend is deployed on Heroku here. Here are my backend logs . I am receiving `users.findOne()` buffering timed out after 10000ms in ...

Customizing the JavaScript code created by the "Change Variable by..." block in Blockly

I'm currently working on a Blockly Project where I am passing data from the blocks as JavaScript code. One of my goals is to make some adjustments to the output code in order to make it more user-friendly for beginners. While it is possible to modify ...

When trying to set the state in the OnMouseOver event, an error is thrown: TypeError - React is

Despite encountering numerous posts discussing this issue, I am struggling to resolve it in my particular scenario. I have a collection of items that I am attempting to apply color changes to (the div's) when they are hovered over. The coloring only ...

No overflow is occurring within the DIV element

This code snippet is fully functional on all browsers except for IE. Unfortunately, the overflow feature does not seem to be working correctly. Any assistance would be greatly appreciated. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ...

Getting the project path in the Sonarqube JavaScript Extension is a straightforward process

I am currently developing a custom rules plugin for the SonarQube Javascript Plugin. I have encountered an issue where I need to disable certain checks in specific directories, such as the bin path. My main question is: how can I obtain the file path rela ...

Total the values of several items within the array

Here is the data I currently have: const arrayA = [{name:'a', amount: 10, serviceId: '23a', test:'SUCCESS'}, {name:'a', amount: 9, test:'FAIL'}, {name:'b', amount: ...

The slider feature is malfunctioning on Internet Explorer version 8

Hello everyone, I am facing an issue with my website located at: http://210.48.94.218/~printabl/ When viewed in IE 8, the slider is not functioning properly (it is showing collapsed between the menu and product images section) The theme used for my site ...

Div element failing to scroll with excessive content

I'm currently working on a modal using Mui Modal and I've encountered an issue. Everything seems to be functioning correctly until I add more items to the cart. When the minHeight exceeds 500, it stops at 100vh and only displays 5 items, even if ...

Turn off ion-slide when the application starts

Is there a way to prevent the slide feature from activating upon startup while still allowing me to set my own active page? I've discovered this helpful snippet in HTML <ion-slide-box active-page="disableSlide()"> <ion-slide>Slide 1& ...

What causes the flex div to inherit the full width of its parent div?

I'm having trouble understanding why a flex div always occupies 100% width of its parent element. Consider the code snippet below: #wrapper { width: 100%; height: 100px; background: green; } #flex { color: white; display: flex; ...