tailwindcss: outline-none doesn't work on button with focus in chrome
Hi,
First of all, a big thank’s for your work on Tailwindcss, it make coding css so cool again !
Maybe it’s not a bug and you thought about this already, but it seems strange that outline-none doesn’t set outline-none on focus too, on button element. I noticed that only on Chrome and only on buttons. If I want to remove outline on focus, I need to do :
<button class="outline-none focus:outline-none">click-me</button>
If not I see a big blue outline when the button is in Focus state.
It seems that’s its coming from normalize.css with :
button:focus {
  outline: 1px dotted;
  outline: 5px auto -webkit-focus-ring-color;
}
If I add outline: none; manually it’s working too.
Is that a normal behaviour ?
About this issue
- Original URL
 - State: closed
 - Created 5 years ago
 - Reactions: 5
 - Comments: 38 (8 by maintainers)
 
You only need
focus:outline-nonefor all browsers:For forms I had to use
focus:ring-0to get it to workworked for me
@desaintflorent I faced the same issue than you. The missing piece is enable “focus” as a variant for outline in tailwind.config.js:
Then you need to add outline on focus:
Hope it helps!
focus:ring-transparentdid it for me on an inputHi ! I have already tried a lots of way but achieved only one.
<button mat-menu-item style="outline: none"> Simply 😄 </button>I don’t like, when I write in style, but if sometimes no way, no problem…hi everyone, i read the docs and i am trying to disable outlines for
button:focus. because i don´t know how to do this specific i followed the docs and added:this, but still… the outline is there… would be happy if someone could help me here. thank you!
Same issue. Adding
focus:ring-0orfocus:ring-transparentsolve the problem of justfocus:outline-none@neural9
@applywill not work for pseudo-class.Do this instead:
This doesn’t work for me in Chrome, I have to add both
outline-noneandfocus:outline-noneto remove the outlineAs of September 2020 the only way I could get this outline to go away was adding
shadow-noneIt looks like browsers now use box-shadow for the outline
Thanks, @TanZng this is working for me.
Tailwind doesn’t add the outline, browsers do. You can remove the outline for all elements if you like by adding a custom base style in your CSS that removes the focus outline but that’s very bad for accessibility so we will never do that by default.
@michabbb try this https://github.com/tailwindlabs/tailwindcss/discussions/2949
If anything, this showed me that I need to look at all my classes, such a large application where I had to do this on each input that had the outline disabled, personal failure.
Yeah the
outline: falsecorePlugin doesn’t appear to work for buttons.I’m trying to use Tailwind with Angular Material and I can’t seem to get rid of the outlines that it adds to Angular components. Angular Material already has it’s own outlines, and I don’t want Tailwind to automatically add any. Is there any way to disable them globally? Adding
focus:ring-0seems to work for forms, but I don’t want to add these classes for every form field and button of my app.