Best way to handle invalid state for InputText when using PassThrough #235
-
I'm using passthrough in PrimeVue and trying to determine the best way to create a style for when the value is invalid using passthrough. Right now I have something like this in my main.ts. I use usePassThrough to merge it with the builtin Tailwind pt.
Then in my component
If invalid is true it'll use the invalid styles I set up in main.ts. It seems a little clunky, just curious if anyone has encountered a better way? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Let's say you did create a custom invalid property:
The
|
Beta Was this translation helpful? Give feedback.
invalid
is not a property or a special context object for PrimeVue components. PrimeVue designer provides some additional class styles likep-invalid
and if you want to add an invalid style class with Tailwind there is a way for this. Firstly, you could find the Tailwind InputText object of PrimeVue here https://primevue.org/inputtext/#theming.tailwind. You may choose to copy-paste or create a custom new Tailwind object.Let's say you did create a custom invalid property:
<InputText type="text" v-model="value" :invalid="true" />
The
pt
object can find all properties from global main.js and then customize it as you wish.