import { useId } from "react"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
export default function Component() {
const id = useId()
return (
<div className="w-full max-w-64 *:not-first:mt-2">
<Label htmlFor={id}>Simple input</Label>
<Input id={id} placeholder="Email" type="email" />
</div>
)
}
Installation
Copy and paste the following code into your project.
"use client"
import * as React from "react"
import { createAnatomy } from "@ark-ui/react/anatomy"
import { type HTMLArkProps, ark } from "@ark-ui/react/factory"
import { cn } from "@/lib/utils"
const anatomy = createAnatomy("input").parts("root")
const parts = anatomy.build()
const Input = React.forwardRef<HTMLInputElement, HTMLArkProps<"input">>(
({ className, type, ...props }, ref) => {
return (
<ark.input
ref={ref}
{...parts.root.attrs}
type={type}
className={cn(
"flex h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none transition-[color,box-shadow] file:inline-flex file:h-7 file:border-0 file:bg-transparent file:font-medium file:text-foreground file:text-sm placeholder:text-muted-foreground/70 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
"focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
"aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",
type === "search" &&
"[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none [&::-webkit-search-results-button]:appearance-none [&::-webkit-search-results-decoration]:appearance-none",
type === "file" &&
"p-0 pr-3 text-muted-foreground/70 italic file:me-3 file:h-full file:border-0 file:border-input file:border-r file:border-solid file:bg-transparent file:px-3 file:font-medium file:text-foreground file:text-sm file:not-italic",
className
)}
{...props}
/>
)
}
)
Input.displayName = "Input"
export { Input }
Update the import paths to match your project setup.
bunx --bun shadcn@latest add @shipbase/input
npx shadcn@latest add @shipbase/input
pnpm dlx shadcn@latest add @shipbase/input
yarn dlx shadcn@latest add @shipbase/input
Usage
import { Input } from "@/components/ui/input"