# 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.

Example: https://hextaui.com/docs/input/examples/native-validation
Component docs: https://hextaui.com/docs/input.md

## Add this example

```bash
npx shadcn@latest add https://hextaui.com/r/input-native-validation.json
```

This adds `components/examples/input/native-validation.tsx` with the Input component and the HextaUI theme tokens.

## Source

```tsx title="components/examples/input/native-validation.tsx"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"

export function InputNativeValidation() {
  return (
    <form className="flex w-full max-w-sm flex-col gap-3">
      <div className="flex flex-col gap-2">
        <Label htmlFor="input-native-email">Email</Label>
        <Input
          id="input-native-email"
          name="email"
          type="email"
          required
          placeholder="you@example.com"
        />
      </div>
      <div className="flex flex-col gap-2">
        <Label htmlFor="input-native-code">Invite code</Label>
        <Input
          id="input-native-code"
          name="code"
          required
          pattern="[A-Z]{4}-[0-9]{4}"
          placeholder="ABCD-1234"
        />
      </div>
      <Button type="submit" className="self-start">
        Join
      </Button>
    </form>
  )
}
```

## Props in this example

### Input

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `type` | `string` | `"text"` |  |

## More Input examples

- [Sizes](https://hextaui.com/docs/input/examples/sizes.md)
- [With a description](https://hextaui.com/docs/input/examples/description.md)
- [Invalid](https://hextaui.com/docs/input/examples/invalid.md)
- [Disabled](https://hextaui.com/docs/input/examples/disabled.md)
- [Read only](https://hextaui.com/docs/input/examples/read-only.md)
- [File](https://hextaui.com/docs/input/examples/file.md)
- [Input types](https://hextaui.com/docs/input/examples/types.md)
- [Controlled](https://hextaui.com/docs/input/examples/controlled.md)
- [With a button](https://hextaui.com/docs/input/examples/with-button.md)
- [Grid](https://hextaui.com/docs/input/examples/grid.md)
- [Long content](https://hextaui.com/docs/input/examples/long-content.md)
- [Right to left](https://hextaui.com/docs/input/examples/rtl.md)
