Input
Single-line text field with Ward's hairline border; the border darkens on focus instead of drawing a ring.
import * as React from "react"
import { cn } from "@/lib/utils"
/*
* Adapted from shadcn/ui (https://github.com/shadcn-ui/ui).
*
* MIT License
*
* Copyright (c) 2023 shadcn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
return (
<input
type={type}
data-slot="input"
className={cn(
"h-9 w-full min-w-0 rounded-md border border-input bg-background px-3 py-1 text-base transition-[color,border-color] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
"focus-visible:border-ring",
"aria-invalid:border-destructive",
className
)}
{...props}
/>
)
}
export { Input }Installation
pnpm dlx shadcn@latest add @ward/inputnpx shadcn@latest add @ward/inputyarn dlx shadcn@latest add @ward/inputbunx --bun shadcn@latest add @ward/inputAdd the Ward registry to components.json once:
"registries": {
"@ward": "https://ward.so/r/{name}.json"
}Or install from the URL with no configuration: npx shadcn@latest add https://ward.so/r/input.json
Copy each file from the Code tab into:
components/ui/input.tsx
Update the import paths to match your project.
Usage
import { Input } from "@/components/ui/input";<Input type="email" placeholder="you@example.com" />
<Input aria-invalid disabled defaultValue="Read only" />Props
| Prop | Type | Default | Description |
|---|---|---|---|
type | string | "text" | The native input type, such as email, password, search or file. |
placeholder | string | - | Hint shown while the field is empty. |
value | string | - | Current value, when the parent controls the field; pair it with onChange. |
aria-invalid | boolean | false | Marks the field as invalid and draws the destructive border. |
disabled | boolean | false | Dim the field and stop it taking focus or input. |
Ward · Version 1.0.0 · Registry manifest