nextui icon indicating copy to clipboard operation
nextui copied to clipboard

[BUG] - Autofilled Input styling is incorrect in dark mode

Open ETOPS7 opened this issue 1 year ago • 5 comments

HeroUI Version

2.8.4

Describe the bug

Autofilled input fields are not styled correctly in the dark theme. The issue occurs on desktop Safari and mobile platforms (Chrome / Safari).

LightMode works correctly, just no autofilled style more You may have disabled this native feature. Test on all devices pls. It would be nice to have a configurable option to enable or disable these global native autofill styles. It is important to note that in mobile browsers it is almost impossible to override the styles of auto-filled data.

Your Example Website or App

https://www.heroui.com/docs/components/input#built-in-validation

Steps to Reproduce the Bug or Issue

  1. Open HeroUI components in Safari (desktop) or Chrome/Safari (mobile).
  2. Navigate to Input component With Form
  3. Autofill the input Email using saved email in browser
  4. Observe the incorrect styling in the dark mode.

Expected behavior

Autofilled input fields should match the dark theme styling consistently native filing

Screenshots or Videos

Image

Operating System Version

Safari version 18.1 (20619.2.8.11.10)

Browser

Safari

ETOPS7 avatar Jan 27 '25 07:01 ETOPS7

Please assign it to me!

GuntreddyHemanth avatar Feb 05 '25 16:02 GuntreddyHemanth

UP ⬆️

ETOPS7 avatar Mar 07 '25 20:03 ETOPS7

Hi, any information regarding when a fix will be released?

lassschr avatar Sep 10 '25 17:09 lassschr

This was my solution for the time being

Problem: On mobile browsers, autofilled HeroUI Input components don't apply proper theme styling (dark mode text appears incorrectly styled).

Root Cause: While HeroUI's onValueChange fires during mobile autofill, the component's internal styling state doesn't update to reflect the "filled" state.

Solution: Force component remount when values change during autofill.

// 1. Add a render key state const [renderKey, setRenderKey] = useState(0);

// 2. Increment key in your change handler const handleInputChange = (value: string) => { setRenderKey(prev => prev + 1); // Forces remount // ... your normal value handling };

// 3. Use key prop on Input component <Input key={input-${renderKey}} value={value} onValueChange={handleInputChange} // ... other props />

How it works: When autofill occurs, onValueChange fires → increments render key → React sees key change → completely remounts Input component → HeroUI starts fresh with the filled value and applies proper styling.

Result: Mobile autofill now immediately displays correct theme styling instead of browser's default autofill colors.

Trade-off: Slight performance impact from component remounting, but solves the visual theming issue entirely.

sapient-christopher avatar Sep 19 '25 01:09 sapient-christopher