Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autofill input in dark mode with Tailwind

I had a problem with ugly colour in input after filling it with remembered password using Dark Mode. In light mode it was yellow, not that bad.

enter image description here

enter image description here

I found some answers using webkit-autofill in SO here, but had problem with implementing it in with tailwind dark: prop and with sass in global.scss file.

like image 363
Werthis Avatar asked Oct 27 '25 22:10

Werthis


1 Answers

The solution was to add this to global.scss file:

@layer components {
  .inputDarkModeOverride {
    &:-webkit-autofill {
      box-shadow: 0 0 0 30px #1c1c1d inset;
    }

    &:-webkit-autofill:hover {
      box-shadow: 0 0 0 30px #1c1c1d inset;
    }

    &:-webkit-autofill:focus {
      box-shadow: 0 0 0 30px #1c1c1d inset;
    }

    &:-webkit-autofill:active {
      box-shadow: 0 0 0 30px #1c1c1d inset;
    }
  }
}

and then className={`${styles.input} dark:inputDarkModeOverride`} in input props.

like image 194
Werthis Avatar answered Oct 30 '25 15:10

Werthis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!