mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-26 22:26:05 +00:00
* feat(form): add form component * feat(www): update site styles * feat: add form examples * docs(www): add docs for forms * docs(www): hide tabs for docs demo
118 lines
2.0 KiB
Plaintext
118 lines
2.0 KiB
Plaintext
---
|
|
title: Input
|
|
description: Displays a form input field or a component that looks like an input field.
|
|
component: true
|
|
---
|
|
|
|
<ComponentExample
|
|
src="/components/examples/input/demo.tsx"
|
|
className="[&_input]:max-w-sm"
|
|
>
|
|
<InputDemo />
|
|
</ComponentExample>
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
npx shadcn-ui add input
|
|
```
|
|
|
|
<Accordion type="single" collapsible>
|
|
<AccordionItem value="manual-installation">
|
|
<AccordionTrigger>Manual Installation</AccordionTrigger>
|
|
<AccordionContent>
|
|
|
|
1. Copy and paste the following code into your project.
|
|
|
|
<ComponentSource src="/components/ui/input.tsx" />
|
|
|
|
<Callout>
|
|
This is the `<Input />` primitive. You can place it in a file at
|
|
`components/ui/input.tsx`.
|
|
</Callout>
|
|
|
|
</AccordionContent>
|
|
|
|
</AccordionItem>
|
|
</Accordion>
|
|
|
|
## Usage
|
|
|
|
```tsx
|
|
import { Input } from "@/components/ui/input"
|
|
```
|
|
|
|
```tsx
|
|
<Input />
|
|
```
|
|
|
|
## Examples
|
|
|
|
### Default
|
|
|
|
<ComponentExample
|
|
src="/components/examples/input/demo.tsx"
|
|
extractClassname
|
|
className="[&_input]:max-w-sm"
|
|
>
|
|
<InputDemo />
|
|
</ComponentExample>
|
|
|
|
---
|
|
|
|
### Disabled
|
|
|
|
<ComponentExample
|
|
src="/components/examples/input/disabled.tsx"
|
|
extractClassname
|
|
className="[&_input]:max-w-sm"
|
|
>
|
|
|
|
<InputDisabled />
|
|
</ComponentExample>
|
|
|
|
---
|
|
|
|
### With Label
|
|
|
|
<ComponentExample src="/components/examples/input/with-label.tsx">
|
|
<InputWithLabel />
|
|
</ComponentExample>
|
|
|
|
---
|
|
|
|
### With Text
|
|
|
|
<ComponentExample src="/components/examples/input/with-text.tsx">
|
|
<InputWithText />
|
|
</ComponentExample>
|
|
|
|
---
|
|
|
|
### With Button
|
|
|
|
<ComponentExample src="/components/examples/input/with-button.tsx">
|
|
<InputWithButton />
|
|
</ComponentExample>
|
|
|
|
---
|
|
|
|
### File
|
|
|
|
<ComponentExample src="/components/examples/input/file.tsx">
|
|
<InputFile />
|
|
</ComponentExample>
|
|
|
|
## React Hook Form
|
|
|
|
<Alert className="mt-4">
|
|
<AlertDescription>
|
|
**Note**: Learn more about using React Hook Form on the
|
|
[docs](/docs/forms/react-hook-form) page.
|
|
</AlertDescription>
|
|
</Alert>
|
|
|
|
<ComponentExample src="/components/examples/input/react-hook-form.tsx">
|
|
<InputReactHookForm />
|
|
</ComponentExample>
|