Cannot style wrapper when invalid input is typed
See original GitHub issueUser can type invalid date into the input field. I’d like to control the styling of the wrapper (.react-date-picker__wrapper
) whenever such situation occurs. Currently this does not seem to be possible as there’s only native :invalid
pseudo-class on the hidden input, which is insufficient as one cannot style parent depending on the state of the child.
Since there’s already .react-date-picker--open
class added for the opened state, could there be .react-date-picker--invalid
for the invalid state?
Alternatively, adding support for onValid
and onInvalid
hooks would also provide the ability to implement custom styling.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
invalid - CSS: Cascading Style Sheets - MDN Web Docs
The :invalid CSS pseudo-class represents any , , or other element whose contents fail to validate.
Read more >CSS highlight label BEFORE an invalid input - Stack Overflow
So if your input is :invalid it will invalidate your fieldset, which you can then reference to style your label.
Read more >Styling input validation errors - OutSystems
So my goal is to create a tooltip box like error message, instead of directly showing the text below the input (sometimes I...
Read more >invalid - CSS-Tricks
The :invalid selector allows you to select elements that do not contain valid content, as determined by its type attribute.
Read more >How to handle invalid user inputs in React forms for UX ...
Even in the case of a single text field, we should wrap the <label> and <input> elements with the <form> element, to allow...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the update! Unfortunately lack of browser support for
:has()
limits its usefulness. I also thought about iterating over all inputs, but that seems a little bit overkill. Ideallyreact-date-picker
should bubble up theinvalid
class name to the main container element 😉Fixed that in
make-event-props@1.3.0
. This didn’t seem to be a burning issue so we won’t create a patch release just to force-bump make-event-props, but if fresh installs or manually installing said dependency should pick the update up.