Changing border color on error? #150
Replies: 1 comment 1 reply
-
Hey @jpalma-savvy thanks for the question
Yeah that seems strange indeed. But I'm not sure it's related to the library. We're not caching any styles or anything like that. So I think the fact that you're able to change the styles one way but not the other points to a problem in your app. Maybe the styles are sticking around somehow? If you could provide a link to a working reproduction (like a repo with a basic rails app) I'd be happy to take a look. Closing for now, but will reopen if it turns out to be library-related. I'd need to look at a reproduction to say for sure. For what it's worth, here are the native styles used by the combobox to show a red border on validation errors: :root {
--hw-invalid-color: #EF4444;
--hw-border-width--thick: 2px;
}
.hw-combobox__main__wrapper {
&:has(.hw-combobox__input--invalid) {
box-shadow: 0 0 0 var(--hw-border-width--thick) var(--hw-invalid-color);
}
} |
Beta Was this translation helpful? Give feedback.
-
I must be overlooking a very simple solution, but I can't seem to find it. I want to change the border color to red when the field has an error inside an activerecord form, and back to its normal state once the validation passes.
I've tried applying it in tailwind inside .field_with_errors, but this doesn't work:
And I've tried to change it dynamically:
But everything I try I can't get it to change the border color to red when there is an error, then back to gray when there is not.
I'm able to style it just fine, but for example in the second example, it will change the border to red when the error happens, but won't change back once the validation passes, and I've removed that style block - it remains red.
I think there is an easier way to do this, but I couldn't find how.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions