Skip to content

Tailwind Plugin

Applies Tailwind CSS utility classes to form fields based on their validation state.

Options

OptionTypeDefaultDescription
validClassstring""Space-separated Tailwind classes applied when the field is valid
invalidClassstring""Space-separated Tailwind classes applied when the field is invalid

Playground

Notes

  • The Tailwind plugin has no default classes. Always pass validClass and invalidClass options. Also add the Message plugin to show error text.
  • Both validClass and invalidClass default to "" — you must provide class names for the plugin to have any visual effect.
  • Supports multiple space-separated classes: "ring-2 ring-green-500 border-green-500".
  • Classes are added to the <input> element directly.
  • On uninstall(), all validation classes are removed.

Released under the MIT License.