Input
A shadcn-style input component built with Ark UI primitives.
import { Input } from "@/components/ui/input";
const InputDemo = () => (
<div className="w-full max-w-md">
<Input placeholder="Enter your email" type="email" />
</div>
);
export default InputDemo;
Installation
npx shadcn@latest add @ark-cn/inputInstall the dependency required by this primitive:
npm install @ark-ui/reactCopy the component source into your app:
TSXcomponents/ui/input.tsx
"use client";
import { ark } from "@ark-ui/react/factory";
import type { ComponentProps } from "react";
import { cn } from "@/lib/utils";
export type InputProps = Omit<ComponentProps<typeof ark.input>, "size"> & {
size?: "sm" | "default" | "lg" | number;
unstyled?: boolean;
nativeInput?: boolean;
};
export const Input = ({
className,
size = "default",
unstyled = false,
nativeInput = false,
...props
}: InputProps) => {
const inputClassName = cn(
"h-8.5 w-full min-w-0 rounded-[inherit] px-[calc(--spacing(3)-1px)] leading-8.5 outline-none [transition:background-color_5000000s_ease-in-out_0s] placeholder:text-muted-foreground/72 sm:h-7.5 sm:leading-7.5",
size === "sm" &&
"h-7.5 px-[calc(--spacing(2.5)-1px)] leading-7.5 sm:h-6.5 sm:leading-6.5",
size === "lg" && "h-9.5 leading-9.5 sm:h-8.5 sm:leading-8.5",
props.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",
props.type === "file" &&
"text-muted-foreground file:me-3 file:bg-transparent file:font-medium file:text-foreground file:text-sm",
);
return (
<span
className={
cn(
!unstyled &&
"relative inline-flex w-full rounded-lg border border-input bg-background not-dark:bg-clip-padding text-base text-foreground shadow-xs/5 ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-disabled:not-has-focus-visible:not-has-data-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] has-focus-visible:has-data-invalid:border-destructive/64 has-focus-visible:has-data-invalid:ring-destructive/16 has-data-invalid:border-destructive/36 has-focus-visible:border-ring has-autofill:bg-foreground/4 has-disabled:opacity-64 has-[:disabled,:focus-visible,[data-invalid]]:shadow-none has-focus-visible:ring-[3px] sm:text-sm dark:bg-input/32 dark:has-autofill:bg-foreground/8 dark:has-data-invalid:ring-destructive/24 dark:not-has-disabled:not-has-focus-visible:not-has-data-invalid:before:shadow-[0_-1px_--theme(--color-white/6%)]",
className,
) || undefined
}
data-size={size}
data-slot="input-control"
>
{nativeInput ? (
<input
className={inputClassName}
data-slot="input"
size={typeof size === "number" ? size : undefined}
{...props}
/>
) : (
<ark.input
className={inputClassName}
data-slot="input"
size={typeof size === "number" ? size : undefined}
{...props}
/>
)}
</span>
);
};
Update import aliases to match your project setup.
Usage
import * as Input from "@/components/ui/input"Read exported parts in src/components/ui/input.tsx and compose the primitive according to the Ark UI pattern for this component.
Examples
import { Input } from "@/components/ui/input";
const InputDemo = () => (
<div className="w-full max-w-md">
<Input placeholder="Enter your email" type="email" />
</div>
);
export default InputDemo;
API reference
This component mirrors the upstream Ark UI primitive. All props and DOM behavior are defined by Ark unless you see an ark-cn-only row below.
Input
| Prop | Type | Description |
|---|---|---|
| size? | "sm" | "default" | "lg" | number | Visual height tier; number forwards to native size attribute. |
| unstyled? | boolean | Skips the bordered control chrome. |
| nativeInput? | boolean | Uses a plain <input> instead of ark.input. |
See the ARK UI documentation for the full API.