The pesky blue line in the input fields just won't go away no matter what I try

Struggling with Bootstrap 5 - need help removing blue line from focused input field.

<div class="container">
<div class="row">
    <div class="col-12">
        <div class="input-group flex-nowrap mt-5">
            <span class="input-group-text" id="addon-wrapping">@</span>
            <input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="addon-wrapping">
        </div>
    </div>
</div>
.input-group input {
  &:focus {
    outline: none !important;;
    box-shadow: none;
  }
}

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

Any help would be appreciated!

Answer №1

The blue line indicates the border color that appears when the input is in focus. To remove this, simply redefine the :focus state of the input and assign your preferred color, typically the color used when the input is out of focus, such as #ced4da (refer to BS5 source code).

To eliminate the shadow effect, you can utilize Bootstrap's shadow-none class on your input element.

.input-group input:focus {
  border-color: #ced4da;
  /** override and maintain the original border color */
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="debcb1b1aaadaaacbfae9eebf0eef0ec">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

<div class="container">
  <div class="row">
    <div class="col-12">
      <div class="input-group flex-nowrap mt-5">
        <span class="input-group-text" id="addon-wrapping">@</span>
        <!-- added "shadow-none" class to the input -->
        <input type="text" class="form-control shadow-none" placeholder="Username" aria-label="Username" aria-describedby="addon-wrapping">
      </div>
    </div>
  </div>
</div>

On a side note, I suggest preserving the border appearance without overriding it, as it serves as a visual indicator that the input is currently focused.

Answer №2

It has been noted by others previously that in order to reset the border-color and box-shadow, you will need to take specific steps.

To achieve this, simply include these two classes within the .form-control:

border shadow-none

Here is a snippet demonstrating this:

<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.1/css/bootstrap.min.css" rel="stylesheet"/>

<div class="container">
<div class="row">
    <div class="col-12">
        <div class="input-group flex-nowrap mt-5">
            <span class="input-group-text" id="addon-wrapping">@</span>
            <input type="text" class="border shadow-none form-control" placeholder="Username" aria-label="Username" aria-describedby="addon-wrapping">
        </div>
    </div>
</div>

Furthermore, it is important to note that the blue border serves a purpose in terms of Accessibility. Therefore, if you choose to remove it, ensure that you provide an alternative method to highlight the selected input.

Answer №3

Bootstrap 5 comes with its own CSS file that includes the following code:

.form-control:focus {
    color: #212529;
    background-color: #fff;
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgb(13 110 253 / 25%);
}

The blue color is defined by the border color property in the code above. To resolve the issue, you can add the following CSS to your stylesheet:

.input-group input {
  &:focus {
    outline: none !important;
    box-shadow: none;
    border-color: #ced4da; /* <- this line here */
  }
}

The color code #ced4da; represents the default color of the bootstrap input border, which can prevent the input from changing color when focused.

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

Ways to optimize the spacing between the menu bar and widgets

I have successfully incorporated multiple images side by side on my blog Following is the code used for this layout: <div class="images"> <figure> <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSA7XLfGrT1rMS-Ifoguz-X2igsT ...

What is the best way to connect added elements together?

I am currently utilizing Plupload to upload files. Due to specific requirements, I need to place FilesAdded "inside" init as demonstrated below. The issue I'm facing is the inability to utilize jQuery.remove() on elements that have been appended usin ...

Is it possible for .php files that don't contain any PHP code to be sent to the interpreter?

Does the PHP interpreter process .php files on a standard LAMP stack even if they do not contain any PHP code? In essence, is there any performance or processing impact in having a .php file without any actual PHP code compared to simply making it an .htm ...

Adding color between lines in Three.js

I have two different sets of vertices. One set contains real vertices, and the other set contains the same vertices but with a y value of zero. I am trying to connect these vertices and fill them in but have not been successful so far. I have attempted to ...

Ways to update the image in a hover container

I am working on a project with HTML code and I am trying to create a hover effect for an image. I want the image to change when hovering anywhere on the box, not just on the image itself. I have tried adding multiple classes and ids, but the image only cha ...

Is there a way to modify the Javascript for this Contact Form to trigger a different action if a specific key is pressed instead?

I have been working on a Contact Form that integrates Google Scripts. Everything seems to be functioning well as it successfully sends emails and formats them properly in my inbox. However, there are two issues that I am encountering: -I want to exclude t ...

Incorporate a glyphicon into a webpage design that wasn't originally built with bootstrap while maintaining the original layout

Looking to jazz up my vintage website with some cool glyphicons on a specific page. Don't want to mess up the entire look of my site by installing bootstrap. Is there a way to add just the "glyphicons functionality" without changing everything else? ...

Discover the method for creating URLs that are relative to the specific domain or server on which they are hosted

I need to adapt my menu bar to cater for different server environments: <a href="http://staging.subdomain.site.co.uk/search/page">Menu</a> The main source site is hosted on an external subdomain from an API service, and I want the URLs in my ...

Error message: ngRepeat does not allow duplicate elements in an array

Upon review, I discovered this particular piece of code: <!DOCTYPE html> <html> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> <body> <script> var app = angular.module("myS ...

Fade in text effect using jQuery on a Mac computer

Trying to create a smooth text fading effect across different browsers using jQuery. In the example below, you may notice that during the last part of the animation when the text fades in, the font weight suddenly increases causing a jerky/clunky appearan ...

``It seems like the Tailwind background image is not appearing on

The issue lies in the background image not displaying despite trying different methods such as using ""bg-[url('/image/example.jpeg')"" tailwind.config.js theme: { extend: { colors: { darkBlue: "#0 ...

Incorporate the HTML CTA on top of the background image within the email template

In my email template, I am trying to place an HTML CTA over a background image. The code works perfectly on all email clients including mobile and desktop, except for Outlook where the alignment of the CTA copy is off. Below is the code snippet along with ...

Utilizing JQuery to modify the element's id and trigger a function upon clicking

There is an element with a specific ID that I have changed. However, even after changing the ID and clicking on the element with the new ID, it still triggers the function associated with the old ID. $('#1st').click(function(){ $('#1s ...

Load iframe once to display on multiple HTML pages

In my web application, I have implemented an iframe that is used on multiple pages. My goal is to load the iframe once on the login screen and have it remain static when navigating to subsequent pages, without refreshing. Is there a way to keep a specific ...

Implementing a jQuery change event to filter a specific table is resulting in filtering every table displayed on the page

I have implemented a change event to filter a table on my webpage, but I am noticing that it is affecting every table on the page instead of just the intended one. Below is the code snippet: <script> $('#inputFilter').change(function() { ...

Tips for ensuring that flex-box children can scroll properly

I'm having trouble getting the content to scroll correctly while dealing with nested flex-box structures. Below is my CSS code: html,body,#root{ width:100%; height:100%; padding:0; margin:0; } .flex-fill{ height:100%; width:100%; ...

add the AJAX response to the specified div element

I'm currently using an ajax call to retrieve movie data from the IMDb API for 'The Shawshank Redemption'. My goal is to display this data within the designated div element. <div id="movie-data"></div> Here's my current Jav ...

Organize the words within HTML elements without considering the tags

My webpage contains buttons that appear as follows: <button>Apple</button> <button>Dog</button> <button>Text</button> <button>Boy</button> <button class='whatNot'>Text</button> <butt ...

Enhance your viewing experience with the Zoom feature that activates when

I recently noticed on that I am able to zoom/enlarge a photo by clicking on it. Is there a way for me to incorporate this feature without purchasing the entire theme? While I understand the theme is designed for purchase, I only need this specific functi ...

How to apply unique styles to multiple elements with the same class using jQuery?

How can I add different classes to multiple div elements with the same class based on their content? <div class = "flag"> Yes </div> <div class = "flag"> No </div> <div class = "flag"> Yes </div> <div class = "flag"& ...