Input 12

PreviousNext

An email input field with error validation and dynamic error message display

Docs
shadcn-studiocomponent

Preview

Loading preview…
registry/new-york/components/input/input-12.tsx
import { useId } from 'react'

import { Input } from '@/registry/new-york/ui/input'
import { Label } from '@/registry/new-york/ui/label'

const InputErrorDemo = () => {
  const id = useId()

  return (
    <div className='w-full max-w-xs space-y-2'>
      <Label htmlFor={id}>Input with error</Label>
      <Input
        id={id}
        type='email'
        placeholder='Email address'
        className='peer'
        defaultValue='invalid@email.com'
        aria-invalid
      />
      <p className='text-muted-foreground peer-aria-invalid:text-destructive text-xs'>This email is invalid.</p>
    </div>
  )
}

export default InputErrorDemo

Installation

npx shadcn@latest add @shadcn-studio/input-12

Usage

import { Input12 } from "@/components/input-12"
<Input12 />