useBollardField

Add touched, async-safe validation state and accessible error props to any React control without changing UI libraries.

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/use-bollard-field.json

The files land in your project. They're yours to edit.

What it catches

  • Validation coupled to a specific input component or UI library
  • Async responses overwriting the result for a newer value
  • Inline errors not connected to controls with aria-describedby
  • Server errors that remain visible after the user edits the field

Accessibility

  • ariaProps connects the control to the error ID and marks invalid state
  • Render the error with id={field.errorId} and role=alert or aria-live=polite
  • No focus movement or UI is imposed; the consuming form chooses its summary behavior

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

  • You provide the validator and render the error message yourself
  • This hook manages one field; it does not replace form submission or schema validation
  • Validation runs on blur, then again after edits; call validate() for submit-time checks

Dependencies

None beyond React and Tailwind CSS.

Pairs well with