UI Logo

UI

Input

A flexible input component for text, number, password, and other input types.

Name must be at least 2 characters

'use client'

import React, { useState } from 'react';
import Input from '@/components/ui/input';

export default function InputDemo() {
  const [value, setValue] = useState('');

  return (
    <div className='flex flex-col items-center justify-center gap-5 lg:flex-row'>
      <Input
        type="text"
        value={value}
        onChange={(e) => setValue(e.target.value)}
        placeholder="Enter your name"
        className="input-primary"
        label="Student Name"
        error={value.length < 5 ? "Name must be at least 5 characters" : ""}
      />
    </div>
  );
}

Installation

Copy and paste the following code into your project.

Update the import paths to match your project setup.

Anatomy

Import all parts and piece them together.

import Input from "@/components/ui/input"
<Input type="text" value="Sample text" onChange={() => {}} />

Props

Type

Type

  • text
  • number
  • password
  • email

Size

Size

  • default
  • small
  • large

Error

Error

  • true
  • false