Input
Input component with smooth animations and modern UI.
Installation
Add this component to your project using the CLI:
terminal
npx vui-registry-cli-v1 add inputSource Code
input.tsx
'use client'
import React from 'react'
import { cn } from '@/lib/utils'
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
/**
* Additional CSS classes to apply to the input
*/
className?: string
}
/**
* Base Input Component
*
* A foundational input component that serves as the base for all input variants.
* This component provides consistent styling and behavior across the input family.
*
* @example
* ```tsx
* <Input placeholder="Enter text..." />
* <Input type="email" placeholder="Email address" />
* <Input type="password" placeholder="Password" />
* ```
*/
export const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, type = 'text', ...props }, ref) => {
return (
<input
type={type}
className={cn(
'flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background',
'file:border-0 file:bg-transparent file:text-sm file:font-medium',
'placeholder:text-muted-foreground',
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
'disabled:cursor-not-allowed disabled:opacity-50',
className,
)}
ref={ref}
{...props}
/>
)
},
)
Input.displayName = 'Input'
// Demo Component
export default function InputDemo() {
return (
<div className="flex flex-col items-center justify-center min-h-[400px] w-full bg-white dark:bg-zinc-950 p-8">
<div className="w-full max-w-md space-y-6">
<div className="text-center space-y-2 mb-8">
<h2 className="text-2xl font-bold tracking-tight">Base Input Component</h2>
<p className="text-zinc-500 text-sm">Foundation for all input variants</p>
</div>
<div className="space-y-4">
<div className="space-y-2">
<label className="text-sm font-medium">Text Input</label>
<Input placeholder="Enter text..." />
</div>
<div className="space-y-2">
<label className="text-sm font-medium">Email Input</label>
<Input type="email" placeholder="email@example.com" />
</div>
<div className="space-y-2">
<label className="text-sm font-medium">Password Input</label>
<Input type="password" placeholder="Enter password" />
</div>
<div className="space-y-2">
<label className="text-sm font-medium">Disabled Input</label>
<Input placeholder="Disabled input" disabled />
</div>
</div>
</div>
</div>
)
}

