Input
A 44px text field with a hairline border and a soft purple focus ring. Mono option for URLs and keys.
Install
$ npx shadcn@latest add @nudgekit/inputOr with no config: npx shadcn@latest add https://ui.nudgekit.app/r/input.json
Usage
usage.tsx
import { Input } from "@/components/ui/input"
<Input placeholder="name@company.com" />
<Input mono defaultValue="https://northwind.io" />Do
- Put every input inside a Field with a label.
- Use mono for URLs, keys and code.
- Use a real example as the placeholder.
Don't
- Use the placeholder as the label.
- Make inputs shorter than 44px.
Code
What the CLI writes into your project. It is yours to change.
components/ui/input.tsx
import * as React from "react";
import { cn } from "@/lib/utils";
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
/** Uses the mono font, for URLs, keys and code. */
mono?: boolean;
}
function Input({ className, mono = false, type = "text", ...props }: InputProps) {
return (
<input
type={type}
data-slot="input"
className={cn(
"h-11 w-full min-w-0 rounded-md border border-input bg-background px-3 text-[15px] text-foreground transition-[border-color,box-shadow] duration-150",
"placeholder:text-faint focus-visible:border-ring focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-brand-tint",
"aria-invalid:border-danger aria-invalid:ring-danger/15 disabled:cursor-not-allowed disabled:bg-surface disabled:opacity-60",
mono && "font-mono text-sm",
className,
)}
{...props}
/>
);
}
export { Input };