# Input

A single-line text input with a focus ring, placeholder styling, and disabled state, forwarding every native input attribute.

- Category: Forms
- License: MIT
- Page: https://www.saasuji.com/components/input
- Install: npx shadcn@latest add https://www.saasuji.com/r/input.json

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| type | `string` | `"text"` | Native input type (text, email, password, number, file, …). |
| placeholder | `string` | — | Hint text shown while the input is empty. |
| disabled | `boolean` | `false` | Disables interaction and reduces opacity. |
| readOnly | `boolean` | `false` | Makes the value non-editable while keeping the input focusable. |
| required | `boolean` | `false` | Marks the input as required for native form validation. |
| value | `string | number | readonly string[]` | — | Controlled value for the input. |
| defaultValue | `string | number | readonly string[]` | — | Initial value for an uncontrolled input. |
| onChange | `React.ChangeEventHandler<HTMLInputElement>` | — | Called on every keystroke with the change event. |
| className | `string` | — | Additional classes merged onto the input. |
| ...props | `React.InputHTMLAttributes<HTMLInputElement>` | — | All remaining native input attributes (name, id, aria-*, autoComplete, …) are forwarded. |

## Source

```tsx
import * as React from "react"
import { cn } from "@/lib/utils"

export type InputProps = React.InputHTMLAttributes<HTMLInputElement>;

const Input = React.forwardRef<HTMLInputElement, InputProps>(
    ({ className, type, ...props }, ref) => {
        return (
            <input
                type={type}
                className={cn(
                    "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
                    className
                )}
                ref={ref}
                {...props}
            />
        )
    }
)
Input.displayName = "Input"

export { Input }

```
