Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An API to disable autofill background color for n-input components #5123

Closed
TrickEye opened this issue Aug 1, 2023 · 1 comment · Fixed by #5127
Closed

An API to disable autofill background color for n-input components #5123

TrickEye opened this issue Aug 1, 2023 · 1 comment · Fixed by #5127
Labels
feature request New feature or request

Comments

@TrickEye
Copy link

TrickEye commented Aug 1, 2023

This function solves the problem (这个功能解决的问题)

This feature request is mainly targeted to the behavior after the autofill feature of the browser is activated.

When a n-input component is autofilled, browsers will add a special background color to the input box through User Agent CSS.

Problem is that the added background color does not suit some of the n-input component very well, for example when the input box has a prefix or suffix icon, or when the input box is in dark mode. They look a little bit weird.

Something like this: I believe the autofilled white background color should expand to the whole input box, but here the background of the suffix icon is still dark.
image

I am looking forward to an API that enables me to modify the autofill background color, or just simply disable it.

Also if naive-ui would like to work on this problem and make the autofill background expand to cover the whole input box, that would be nice too!

Expected API (期望的 API)

<n-input placeholder="pswd" autofillbg="disabled">
@github-actions github-actions bot added the feature request New feature or request label Aug 1, 2023
jizai1125 added a commit to jizai1125/naive-ui that referenced this issue Aug 3, 2023
jizai1125 added a commit to jizai1125/naive-ui that referenced this issue Aug 3, 2023
07akioni added a commit that referenced this issue Dec 19, 2023
* fix(input): autofill's default background color, closes #5123

* Update src/input/src/styles/input.cssr.ts

---------

Co-authored-by: 07akioni <07akioni2@gmail.com>
@07akioni
Copy link
Collaborator

07akioni commented Jan 6, 2024

I've tried various solutions, nothing fits all browser. So we won't provide builtin solution to disable autofill background color.

If you need to disable it for modern chrome, you may use:

.n-input input {
  -webkit-background-clip: text;
  -webkit-text-fill-color: var(--n-text-color);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants