Input: Native validation
Fields with required, type="email" or pattern only turn red after someone has typed in them or tried to submit, never on first render. A submit that finds a field invalid shakes it once, so the eye lands on what needs fixing. It never shakes while you type or tab around. Submit the empty form to see it.
This adds the example as components/examples/input/native-validation.tsx, together with the Input component and the HextaUI theme tokens it needs.
pnpm dlx shadcn@latest add https://hextaui.com/r/input-native-validation.jsonTo add only the component, follow the Input installation.
Props in this example
The Input props this example sets, from the API reference.
| Prop | Type | Default |
|---|---|---|
type | string | "text" |
Every prop is in the Input API reference.
- Sizes
- With a description
- Invalid
- Disabled
- Read only
- File
- Input types
- Controlled
- With a button
- Grid
- Long content
- Right to left
See them all, with keyboard support and accessibility notes, on the Input page.
- MotionThe easing curves, durations and reduced-motion check every component animates with, plus hooks for size morphs and sliding highlights.
- Number flowAnimated numbers where only the changed digits spin, with any Intl format and locale.
- useAutosizeGrows a textarea with what you write between its minimum and maximum height, animating each change without ever touching the text.
- useComposedRefKeeps a ref to your own element while still forwarding it to whatever ref the parent passed in.
- useInvalidShakeShakes a form control when a submit attempt finds it invalid, and never while someone is still typing.
- useMergedRefCombines any number of callback and object refs into one, with React 19 ref cleanup for each of them.