How to remove the blue halo glow from jQuery Mobile elements

Written by on April 7, 2015

How to remove the blue halo glow from jQuery Mobile elements

I hate jQuery Mobile blue halo outline effect and so should you, otherwise you would not be here. There are several solutions to this problem and I will name few of them.

Note: If this tutorial was helpful, you need further clarification, something is not working or you have a request for another Ionic post? Furthermore, leave me a comment below if you don't like something about this blog, if something is bugging you, don't like how I'm doing stuff here. Feel free to comment below, subscribe to my blog, mail me to dragan.gaic@gmail.com. Thanks and have a nice day!

Solution 1 – JavaScript

<input type="text" value="text" class="nohalo"/>
<p>Shadow removed - search input</p>
<input type="search" placeholder="Search.." value=""  class="nohalo"/>
<p>Shadow removed - number input</p>
<input type="number" value="12345"  class="nohalo"/>
<input type="password" value="foo"  class="nohalo"/>
<input type="email" value="email@me.net"  class="nohalo"/>
<input type="date"  class="nohalo"/>
$(document).on('focus', 'input', function () {
    if ($(this).hasClass('nohalo')) {
        $(this).closest('div').addClass('noshadow');
    }
});
.ui-focus {
 -moz-box-shadow: none !important;
 -webkit-box-shadow: none !important;
 box-shadow: none !important;
}

This is a JavaScript solution which requires a custom class set to every input box we want to change, name it any way you want. Use this solution if you only want to target a certain type of elements.

Working Plunker example can be found here:

Demo

Embedded example:

Solution 2 – Pure CSS solution

.ui-focus,
.ui-btn:focus {
    -moz-box-shadow: none !important;
    -webkit-box-shadow: none !important;
    box-shadow: none !important;
}

This is an all around solution, it will completely remove this feature from jQuery Mobile. !important keyword is necessary, it will not work without it.

Working Plunker example can be found here:

Demo

Embedded example:

Solution 3 – Replace blue halo with other color

.ui-focus,
.ui-btn:focus {
    -moz-box-shadow: inset 0 0 3px      #555  , 0 0 9px         #555  !important;
    -webkit-box-shadow: inset 0 0 3px   #555  , 0 0 9px         #555  !important;
    box-shadow: inset 0 0 3px           #555  , 0 0 9px         #555  !important;
}
.ui-input-text.ui-focus,
.ui-input-search.ui-focus {
    -moz-box-shadow: 0 0 12px           #555 !important;
    -webkit-box-shadow: 0 0 12px        #555 !important;
    box-shadow: 0 0 12px                #555 !important;    
}

Use this solution if you still want to use a halo effect but blue color is not working for you.

Working Plunker example can be found here:

Demo

Embedded example:

Who Am I?

Between working as a senior Java developer in one of the largest insurance companies in the world and traveling, in my free time, I work as a professional mobile development adviser. I'm also a major jQuery Mobile supporter back at StackOverflow and a forum moderator at the official Ionic Framework forum.



Categories

1 thought on “How to remove the blue halo glow from jQuery Mobile elements”

Leave a Reply