Getting Started
Components52
- Accordion
- Alert
- Alert Dialog
- Attachment
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Checkbox
- Collapsible
- Command
- Context Menu
- Data Table
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Item
- Kbd
- Label
- Marker
- Menubar
- Message
- Message Scroller
- Pagination
- Popover
- Progress
- Questionnaire
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
import { Input } from "@/components/ui/input"
export function InputDemo() {
return <Input placeholder="Search apps" className="max-w-xs" />
}Installation#
pnpm dlx shadcn@latest add https://ui.ikramhasan.com/r/input.json
Usage#
import { Input } from "@/components/ui/input"<Input />Examples#
With label and hint#
The address you sign in to Shopify with.
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
export function InputWithLabelAndHint() {
return (
<div className="flex w-full max-w-xs flex-col gap-1.5">
<Label htmlFor="store-url">Store URL</Label>
<Input
id="store-url"
placeholder="your-store.myshopify.com"
aria-describedby="store-url-hint"
/>
<p
id="store-url-hint"
className="text-[13px] leading-4 text-muted-foreground"
>
The address you sign in to Shopify with.
</p>
</div>
)
}Invalid#
Enter a URL ending in .myshopify.com
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
export function InputInvalid() {
return (
<div className="flex w-full max-w-xs flex-col gap-1.5">
<Label htmlFor="store-url-invalid">Store URL</Label>
<Input
id="store-url-invalid"
defaultValue="mystore.com"
aria-invalid
aria-describedby="store-url-error"
/>
<p
id="store-url-error"
className="text-[13px] leading-4 text-destructive"
>
Enter a URL ending in .myshopify.com
</p>
</div>
)
}Disabled#
import { Input } from "@/components/ui/input"
export function InputDisabled() {
return <Input disabled placeholder="Disabled" className="max-w-xs" />
}File#
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
export function InputFile() {
return (
<div className="flex w-full max-w-xs flex-col gap-1.5">
<Label htmlFor="logo">Logo</Label>
<Input id="logo" type="file" />
</div>
)
}With button#
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
export function InputWithButton() {
return (
<form className="flex w-full max-w-sm items-center gap-2">
<Input type="email" placeholder="Email" aria-label="Email" />
<Button type="submit" variant="secondary">
Subscribe
</Button>
</form>
)
}API Reference#
Input is built on the Base UI Input primitive. See the Base UI documentation for every prop.