Input Component

The Input component is a flexible, modern form input designed for SaaS applications. Perfect for React authentication UI, form builders, and SaaS dashboard interfaces. Built with Tailwind CSS for responsive design and supports multiple types (text, password, email, number, url, tel, search, textarea). Features include prefix/suffix icons, inline validation states, helper text, multiple sizes, and a password visibility toggle.

Import Component From Library

javascript
1import { Input } from "@neuctra/ui";

Basic Usage Code

Start with a simple input field. The component supports various input types including text, password, email, number, and textarea.

jsx
1import { Input } from '@neuctra/ui';
2
3function BasicExample() {
4  return (
5    <Input
6      label="Name"
7      placeholder="Enter your name"
8      onChange={(e) => console.log(e.target.value)}
9    />
10  );
11}

Basic Example

Input Types

Supports multiline input

States & Validation

Looks good!

Sizes

Props Table

All available props for the Input component.

PropTypeDefaultDescription
labelstring—Label text for the input field.
namestring""Input name attribute.
type"text" | "password" | "email" | "number" | "url" | "tel" | "search" | "textarea""text"Input type.
idstring—HTML id attribute for accessibility.
descriptionstring—Descriptive text shown next to label.
placeholderstring""Placeholder text inside the input.
valuestring—Controlled input value.
defaultValuestring""Initial value for uncontrolled usage.
onChange(event) => void—Triggered when input value changes.
onFocus(event) => void—Triggered when input gains focus.
onBlur(event) => void—Triggered when input loses focus.
requiredbooleanfalseMarks field as required.
disabledbooleanfalseDisables the input.
readOnlybooleanfalseMakes input read-only.
errorstring | booleanfalseShows error state or message.
successbooleanfalseDisplays success state.
helperTextstring—Helper text below the input.
iconReact.ElementType—Icon displayed inside the label.
prefixstring—Text shown before input value.
prefixIconReact.ElementType—Icon before input content.
suffixIconReact.ReactNode—Icon after input (ignored for password toggle).
min / max / stepnumber—Constraints for number input.
maxLengthnumber—Maximum character length.
rowsnumber4Textarea rows.
size"sm" | "md" | "lg""md"Input size variant.
wrapperClassNamestring—Custom classes for wrapper.
labelClassNamestring—Custom classes for label.
inputClassNamestring—Custom classes for input.
textareaClassNamestring—Custom classes for textarea.
prefixClassNamestring—Custom classes for prefix.
suffixClassNamestring—Custom classes for suffix.
helperTextClassNamestring—Custom classes for helper text.
descriptionClassNamestring—Custom classes for the description text next to the label.
wrapperStyleCSSProperties—Inline styles for wrapper.
inputStyleCSSProperties—Inline styles for input/textarea.
labelStyleCSSProperties—Inline styles for label.

Common Mistakes

<Input type="textarea" rows={0} />

rows must be >= 1 for textarea rendering.

<Input type="number" min={10} max={5} />

min should always be less than max.

<Input id="email" label="Email" />

Always use label + id for accessibility.

Pro Tips

  • Use size prop for responsive layouts (sm, md, lg).
  • Use prefix/prefixIcon for visual context (currency, domain, etc).
  • Combine error/success with helperText for user feedback.
  • Always provide id and label for accessibility.
  • Use description prop to show optional/required hints.
  • Password inputs automatically include visibility toggle via Eye icon.
  • Controlled vs uncontrolled: use value or defaultValue.

Frequently Asked Questions

How do I install and import the Input component?

Install the @neuctra/ui package, then import it with: import { Input } from "@neuctra/ui";

What variants and sizes does Input support?

Input supports sizes: sm, md, lg. Use the variant and size props to switch between them, or pass a className to layer on custom Tailwind CSS classes.

Is the Input component accessible?

Input is built with semantic HTML and standard ARIA attributes, and supports keyboard navigation and focus states out of the box, so it works well with screen readers and keyboard-only users.

Built with React, Tailwind CSS & TypeScript.