Preview

Installation

<> import.ts
import { Input } from "@/components/ui/input"

Code

<> component.tsx
import { Input } from "@/components/ui/input"

<Input placeholder="Enter your email" />
<Input type="password" placeholder="Password" />

API Reference

Input

Displays a form input field.

<> import.ts
import { Input } from "@/components/ui/input"

Props

PropTypeDefaultDescription
label
stringLabel text for the input
placeholder
string"Enter text..."Placeholder text for the input
type
"text" | "email" | "password" | "number" | "tel" | "url" | "file""text"Type of the input field
isLabel
booleanfalseWhether to show the label
isWithIcon
booleanfalseWhether to show an icon
customIcon
React.ReactNodeCustom icon to display
isWithButton
booleanfalseWhether to show a button next to input
className
string""Additional CSS classes
value
stringValue of the input
onChange
(e: React.ChangeEvent<HTMLInputElement>) => voidChange handler for the input
onFocus
(e: React.FocusEvent<HTMLInputElement>) => voidFocus handler for the input
onBlur
(e: React.FocusEvent<HTMLInputElement>) => voidBlur handler for the input
onKeyDown
(e: React.KeyboardEvent<HTMLInputElement>) => voidKey down handler for the input
onButtonClick
() => voidClick handler for the button
buttonText
string"Submit"Text for the button
disabled
booleanfalseWhether the input is disabled
bg
booleanfalseWhether to show background color
accept
stringAccept attribute for file inputs

Examples

Example 1
<> example.tsx
// Basic input
<Input placeholder="Enter your name" />
Example 2
<> example.tsx
// Input with label
<Input 
  isLabel={true}
  label="Name"
  placeholder="Enter your name" 
/>
Example 3
<> example.tsx
// Input with icon
<Input 
  isWithIcon={true}
  placeholder="Search..." 
/>
Example 4
<> example.tsx
// Input with custom icon
<Input 
  isWithIcon={true}
  customIcon={<SearchIcon />}
  placeholder="Search..." 
/>
Example 5
<> example.tsx
// Input with button
<Input 
  isWithButton={true}
  buttonText="Submit"
  placeholder="Enter email"
  onButtonClick={() => console.log('Submitted')}
/>
Example 6
<> example.tsx
// Different input types
<Input type="email" placeholder="Enter email" />
<Input type="password" placeholder="Enter password" />
<Input type="number" placeholder="Enter number" />