Docs
Text Input
Text Input

A flexible text input component with validation, variants, and Zod integration for modern forms.

Enter a unique username for your account

Overview

The Text Input component provides a robust foundation for single-line text entry with comprehensive validation and styling options, essential for user data collection in modern forms. It supports both default and pill variants with customizable borders, real-time validation, and excellent accessibility features. Perfect for email addresses, usernames, search fields, and any scenario requiring clean, validated text input with optimal user experience.

Installation

pnpm dlx shadcn@latest add https://deltacomponents.dev/r/text-input.json

Usage

"use client"
 
import { TextInput } from "@/registry/inputs/text-input"
 
export function Component() {
  return (
    <TextInput
      label="Email Address"
      name="email"
      type="email"
      placeholder="Enter your email"
      description="We'll use this to send you updates"
      required
      onChange={(e) => console.log("Value:", e.target.value)}
    />
  )
}

API Reference

Props

PropTypeDefaultDescription
labelstring-Label for the input field (required)
namestring-Name of the input field for form submission (required)
descriptionstringundefinedDescription text below the label
hintstringundefinedHint text below the input
errorstringundefinedError message to display
requiredbooleanfalseWhether the field is required
pendingbooleanfalseWhether the field is in a loading state
defaultValuestringundefinedDefault value for the input
disabledbooleanfalseWhether the input is disabled
idstringnameID for the input element
typestring"text"HTML input type
placeholderstringundefinedPlaceholder text
variant"default" | "pill""default"Visual variant of the input
coloredBorderbooleanfalseWhether to show colored border (pill variant)
labelVariant"default" | "muted""default"Label text styling variant
containerClassNamestring""CSS classes for the container
labelClassNamestring""CSS classes for the label
schemaZodType<string>undefinedZod schema for validation
onValidate(isValid: boolean, value: string, error?: string) => voidundefinedValidation callback

All standard HTML input attributes are also supported and passed through to the underlying input element.

Examples

Pill Variant

Rounded pill variant with muted background for modern form interfaces.

Pill variant with colored border