HextaUI

Input: Invalid

aria-invalid turns the edge and the focus ring red. Link the message with aria-describedby so it is announced, not just colored.

Enter a full email address, like [email protected].

import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"

export function InputInvalid() {
  return (
    <div className="flex w-full max-w-sm flex-col gap-2">
      <Label htmlFor="input-invalid">Email</Label>
      <Input
        id="input-invalid"
        type="email"
        defaultValue="preet@"
        aria-invalid
        aria-describedby="input-invalid-error"
      />
      <p id="input-invalid-error" className="text-sm text-destructive">
        Enter a full email address, like [email protected].
      </p>
    </div>
  )
}

This adds the example as components/examples/input/invalid.tsx, together with the Input component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/input-invalid.json

To add only the component, follow the Input installation.

Props in this example

The Input props this example sets, from the API reference.

PropTypeDefault
defaultValue
string | number | string[]–
type
string"text"
aria-invalidShows the invalid edge and focus ring.
boolean–

Every prop is in the Input API reference.

See them all, with keyboard support and accessibility notes, on the Input page.