1

Solution: Webkit Tap Highlight Color

I have an input field that is a textbox. When a user taps it on mobile, it briefly flashes a black shadow around the box like in the picture related.

The following GIF image is a screen recording of the bar being tapped on a mobile device. How do I stop the black shadow from flashing around the box for a split second when it is tapped?

Textbox gif

enter image description here

.searchBar {
  height: 46px;
  border-radius: 2px;
  background-color: #fff;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  box-shadow: 0 2px 2px 0 rgb(0 0 0 / 20%), 0 0 0 1px rgb(0 0 0 / 13%);
}

.searchBox {
  flex: 1;
  border: none;
  background-color: transparent;
  padding: 17px;
  font-size: 16px;
  color: #000;
  outline: none !important;
  box-shadow: none !important;
  -moz-appearance: none;
  -webkit-appearance: none;
}

.searchButton {
  border: none;
  background-color: transparent;
  height: 46px;
  width: 46px;
  padding-right: 17px;
  justify-content: center;
  outline: none !important;
  cursor: pointer;
  display: inline;
}
<div class="searchBar">

  <input class="searchBox">

  <button class="searchButton" type="submit" value="Search"><i class="fas fa-search"></i> </button>

</div>

3 Answers3

3

I couldn't see any shadow flashes in the output of your code.But this may help i used this to remove the blue tap color that appears while clicking on button. Just add this

*{      
-webkit-tap-highlight-color: transparent;
 }
ac_mmi
  • 2,302
  • 1
  • 5
  • 14
2
.searchbox:focus {
        outline: none !important;
        border: none;
        box-shadow: none;
    }

Refer it here: How to change border color of textarea on :focus

  • This issue does not appear to be related to outline, box-shadow, or border –  Feb 08 '21 at 02:09
0

I have modified your code, can you please check if it is working? I have used box-shadow in the searchBox not searchBar and all css property initial.

.searchBar {
  height: 46px;
  border-radius: 2px;
  background-color: #fff;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
}

.searchBox,
.searchBox:focus,
.searchBox:active{
  all: initial;
  flex: .1;
  background-color: transparent;
  padding: 5px 17px;
  box-sizing: border-box;
  font-size: 16px;
  color: #000;
  -moz-appearance: none;
  -webkit-appearance: none;
  box-shadow: 0 2px 2px 0 rgb(0 0 0 / 20%),0 0 0 1px rgb(0 0 0 / 13%);
  border: none;
  outline: none;
}

.searchButton {
  border: none;
  background-color: transparent;
  height: 46px;
  width: 46px;
  padding-right: 17px;
  justify-content: center;
  outline: none !important;
  cursor: pointer;
  display: inline;
}
<link href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" rel="stylesheet"/>
<div class="searchBar">

  <input class="searchBox" type="search">

  <button class="searchButton" type="submit" value="Search"><i class="fas fa-search"></i> </button>

</div>
NIKHIL CHANDRA ROY
  • 807
  • 11
  • 16