-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[BUG] - Input slot override styles not working for pseudo-classes #4878
Comments
try data-[hover=true]:bg-blue-500 ? |
Strange! I have updated my example website link to reflect the code below: <Input
label="Hover"
classNames={{
inputWrapper: ['data-[hover=true]:bg-blue-700'], // The only one that applies
input: ['data-[hover=true]:text-white'], //Does not apply
}}
/>
<Input
isInvalid
label="Invalid"
classNames={{
inputWrapper: ['data-[invalid=true]:bg-blue-700'], //Does not apply
input: ['data-[invalid=true]:text-white'], //Does not apply
}}
/>
<Input
label="Focus"
classNames={{
inputWrapper: [
'data-[focus-visible=true]:bg-blue-700', //Does not apply
'data-[focus-within=true]:bg-blue-700', //Does not apply
'data-[focus=true]:bg-blue-700', //Does not apply
],
input: [
'data-[focus-visible=true]:text-white', //Does not apply
'data-[focus-within=true]:text-white', //Does not apply
'data-[focus=true]:text-white', //Does not apply
],
}}
/>
<Input
isDisabled
label="Disabled"
classNames={{
inputWrapper: ['data-[disabled=true]:bg-blue-700'], //Does not apply
input: ['data-[disabled=true]:text-white'], //Does not apply
}}
/> |
I think you can know how the styles are defined by looking at the style file and override exactly. https://github.com/heroui-inc/heroui/blob/canary/packages/core/theme/src/components/input.ts |
HeroUI Version
@heroui/[email protected]
Describe the bug
When adding styles to pseudo-classes of the slots of within Input, they are not applied or immediately overridden.
For example: adding
hover-bg-blue-500
toinputWrapper
results in a blue background when the cursor is hovering on the input during a reload. But if the user triggers onBlur, and then triggers onHover again, the styles are not applied (see video).Your Example Website or App
https://stackblitz.com/edit/stackblitz-starters-kg41cf2d?file=app%2Fpage.tsx
Steps to Reproduce the Bug or Issue
classNames
prop to<Input>
Expected behavior
As a user, I expect the styles for pseudo-classes on slots to apply to the Input component, so that I can style states such as invalid and hover.
I have attempted to override with both
[class]-[style]
,data-[class]-[style]
, and creating new CSS modules, however they result in the same outcome.Screenshots or Videos
Screen.Recording.2025-02-19.at.11.19.19.PM.mov
Operating System Version
MacOS
Browser
Chrome
The text was updated successfully, but these errors were encountered: