How to hide autofill safari icon in input field
Asked Answered
I

9

43

Every one of my input fields has the little person icon with the arrow in safari. How to I disable that? By the way, I have any other similar page and that's not happening. I tried turning off all styles in the web inspector and the one page still has the icon.

Immemorial answered 29/7, 2016 at 16:32 Comment(2)
So it looks like Safari is actually parsing my text. This is supposed to be an admin type page where you enter customer information. Safari wants the user to enter their own information. How do I disable the icon?Immemorial
I wrote a blog about this: jrnv.nl/…Dovetail
M
72

If you want to hide it completely, you can use the following css tricks. Basically it detect that 'contacts-auto-fill-button' and move it away from your input field. Make sure you have 'absolute:position' to avoid extra padding from your fields.

input::-webkit-contacts-auto-fill-button {
  visibility: hidden;
  display: none !important;
  pointer-events: none;
  position: absolute;
  right: 0;
}
Mauk answered 5/10, 2016 at 23:11 Comment(8)
I'm curious...is this working for anyone? I haven't been able to hide the auto fill button without turning off autofill in Safari preferences.Ician
@Ician I think the case was you still get that ugly "user" icon even you have autocomplete="off" on <input> fields, in this case we are forcefully hiding that icon. Turning off autofill in preferences is different hardcore solution that we (developer) can't force users to do that.Mauk
For Safari 11 {visibility: hidden} is enoughSalters
Hey @JimbaTamang - This CSS helped me to hide the contact icon on the right side. Even though, when I type a contact which exists in my list, it shows the dropdown with those contacts. Is there a way to hide this as well?Contreras
@TibinPaul can you setup demo somewhere so that we can have a look?Mauk
@JimbaTamang Does this not work anymore? The contact list still pops up for me in Safari with this codeNotable
I had to add input::-webkit-contacts-auto-fill-button{width: 0} to make it work.Uniformitarian
correct selector is input::-webkit-credentials-auto-fill-buttonDictatorial
S
25

You don't have to cancel all properties of the autofill buttons.

To hide Safari's icons altogether, you can also just hide its wrapper.

As the icons are Shadow Content, the DOM won't show it but the shadow DOM does. Just turn on the '<>'-button in the inspector.

There you'll find the wrapping container you can target with css like this:

input::-webkit-textfield-decoration-container {
  display: none; /* or whatever styling you want */
}

Inside you will find the password keychain and the caps-lock indicator:

input::-webkit-caps-lock-indicator {
}

input::-webkit-credentials-auto-fill-button {
}

Oh, and while you're at it, don't forget IE with its clear buttons and password eye icons:

input::-ms-clear {
}

input::-ms-reveal {
}
Sextillion answered 7/9, 2017 at 8:57 Comment(3)
This appears to be the best answer.Powel
This also gets rid of any placeholder text along with the icon.Midwest
Use input::-webkit-textfield-decoration-container { opacity: 0 } "display: none will cause placeholder issue"Bathometer
P
17

Hide autofill Safari icon in input password field:

::-webkit-credentials-auto-fill-button {
    visibility: hidden;
    position: absolute;
    right: 0;
}
Pyjamas answered 28/2, 2017 at 18:20 Comment(1)
pointer-events: none is superfluous. visibility: hidden already prevents pointer events.Immunology
T
7

Related: I wanted to adjust the position of the the key icon for a input[type="password"] but couldn't find the pseudo element selector anywhere.

So I cloned the webkit source and was able to find it :)

input::-webkit-credentials-auto-fill-button

Tieback answered 28/2, 2017 at 3:37 Comment(0)
H
4

https://static.mcmap.net/file/mcmap/ZG-AbGLDKwfpKnMxcF_AZVLQamyA/qgYIE.png

If you use <input> field without wrapping it in <form> tag, Safari 11+ or latest would show you auto-fill suggestion. So here is what you can do.

Option 1: Make sure <input> elements are wrapped inside <form> element. Don't set value of name attribute to "username" or "login".

Option 2: Add name attribute and set its value as "search". <input type="text" name="search">

Note: Using autocomplete="off" or autocomplete="false" on either <form> and <input> would not help. Neither adding following CSS properties would work.

input::-webkit-autofill,
input::-webkit-contacts-auto-fill-button,
input::-webkit-credentials-auto-fill-button
Hieroglyphic answered 27/8, 2019 at 15:41 Comment(0)
C
3

As a note – check your field labels and any placeholder attribute values too – as these can also cause autocomplete popups to appear, despite CSS styling rules being applied to the contrary.

See below for more detail...


It should be noted that in Safari (version 11+ at least, and likely earlier versions too, and other recent browsers, e.g. Chrome, Firefox, etc), that even if the various CSS workarounds to hide the autocomplete popups are in place, if the field appears to be a username or password field to the browser, then the autocomplete field still appears.

I found that the browser is not only checking the <input> tag's name attribute for keywords such as username, login and similar variants, but also appears to consider the contents of any placeholder attribute text on the field, as well as most surprisingly, any text adjacent to the <input> field such as that used as a form field label. The label text does not need to be placed into a <label> tag to have this effect - just to be in close proximity to the field, although I haven't had opportunity to extensively test and determine what is considered 'close proximity' - this will require some further research and experimentation or where possible, review of the various web browser rendering engines' source code - such as for WebKit.

As such if you have keywords word such as username, user name, login or similar variants, as well as variants for password, the browser will show the autocomplete popup when the field is focussed, despite any CSS rules to try and hide it!

While I was not as surprised to see the popup being activated by the <input> tag's name or placeholder attribute values, I was surprised to see that label text was considered too by the browser, as such I had to change the wording and labelling of the fields to ensure the popups did not appear. I found for example modifying the placeholder text from 'Please enter your username...' to 'Please enter your user-name...' prevented the browser from recognizing the field as a username field – also notice the hyphen between the words user and name – without the hyphen between the words – the popup still appeared, so it shows how may edge cases the browsers are checking for. As a note, I had already modified the field's name attribute and the adjacent labelling by this stage to remove references to the triggering keywords or their variants.

It is clear that browsers are doing some interesting page inspection to determine if to show username/password popups - and while this is great overall behavior that helps encourage users to take advantage of password managers for more secure credential generation and storage, there are times when you don't want the autocomplete popup to appear. There are use-cases such as within an admin interface that allow administrators to manage staff user accounts for example - where you want to offer a field to search for a staff user by their username. In cases like this you don't want the autocomplete popup to try and fill the field with your own username, but rather allow you to enter any number of staff usernames for example. It would be great if one of the standard autocomplete='off' flags or a future variant could be adopted by the browser vendors to provide this clean control of the autocomplete behavior or a standard CSS attribute that if applied always had the intended effect... but alas this is not currently the case.

For now however, if you are dealing with this issue, make sure you are also considering the contents of any placeholder attribute you have added to any username or password <input> fields - as well as any label-like text that appears nearby. By adjusting and experimenting with the values of these labels/attributes you should be able to work around the page-inspection logic the browsers are using to enable these autocomplete popups.

As always with the web, and as some of browser's rendering engines are closed-source, this will likely continue to be more of an art than a science, until a standard is developed to provide control of this feature for all browsers on all platforms, and it may be necessary to occasionally revisit the code to check it against new browser versions to ensure that popups are not re-appearing due to changed page-inspection logic.

Cleat answered 9/8, 2018 at 19:6 Comment(1)
We had an issue, where a label close to an input field (provided by a react-select dropdown component) contained the word "e-mail". Even though the input field itself didn't have anything to do with "emails", the select component was overlapped by safaris "hide my email"-popover. Adding a Soft Hyphen-Unicode-Character (U+00AD) within the word "e-mail" prevented the popup showing.Huebner
F
0

Even with visibility:hidden or/and display:none Safari Ios keeps popping up icons and buttons. For me, the best solution was to set opacity to 0. This doesn't remove unwanted icons, but makes them completely transparent, and thus invisible. Furthermore, it works on whatever background color or img you're using.

input::-webkit-contacts-auto-fill-button {
opacity: 0;
}
Flash answered 25/1, 2020 at 11:18 Comment(0)
H
0

The answers are all correct, however most of them are just curing the symptoms. Mostly, you just need to check your name attribute. In case you didn't give any name, name your input something. This helped in my case as without a name safari makes mistakes in recognizing autofillable inputs

Helvetia answered 13/1, 2023 at 9:56 Comment(0)
R
0

All the above was not enough, the little key for the auto-fill was there on input focus. I added this to my css:

input::-webkit-credentials-auto-fill-button{
     visibility: hidden;
}
Runstadler answered 23/1 at 8:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.