# Input

Displays a form input field or a component that looks like an input field.

## Installation

```bash
npx shadcn@latest add https://reactdocs.canceydejean.dev/r/input.json
```

[Registry JSON](https://reactdocs.canceydejean.dev/r/input.json)

## Preview

```tsx
import { Input } from "@/components/ui/input/input";

export function Preview() {
  return <Input type="email" placeholder="Email" className="max-w-xs" />;
}
```


## Source

### input.tsx

```tsx
import { Input as InputPrimitive } from "@base-ui/react/input";
import * as React from "react";

import { cn } from "cn";

function Input({ className, type, ...props }: React.ComponentProps<"input">) {
  return (
    <InputPrimitive
      type={type}
      data-slot="input"
      className={cn(
        "border-input file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 disabled:bg-input/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 h-8 w-full min-w-0 rounded-lg border bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-3 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3 md:text-sm",
        className,
      )}
      {...props}
    />
  );
}

export { Input };
```



## Usage

Use inputs for text, email, password, search, file, and other single-line fields.

```tsx
import { Input } from "@/components/input/input";

export function Example() {
  return <Input type="email" placeholder="Email" />;
}
```

Supports native `type` values, `disabled`, and `aria-invalid` for form error styling. Built on
Base UI Input.

