Textarea
Multi-line text field that grows with its content and shows focus and invalid states.
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 Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
return (
<textarea
data-slot="textarea"
className={cn(
"flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-background px-3 py-2 text-base transition-[color,border-color] outline-none placeholder:text-muted-foreground focus-visible:border-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive md:text-sm",
className
)}
{...props}
/>
)
}
export { Textarea }Installation
pnpm dlx shadcn@latest add @ward/textareanpx shadcn@latest add @ward/textareayarn dlx shadcn@latest add @ward/textareabunx --bun shadcn@latest add @ward/textareaAdd 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/textarea.json
Copy each file from the Code tab into:
components/ui/textarea.tsx
Update the import paths to match your project.
Usage
import { Textarea } from "@/components/ui/textarea";<Textarea placeholder="What should we know about this site?" />
<Textarea aria-invalid disabled defaultValue="Read only" />Props
| Prop | Type | Default | Description |
|---|---|---|---|
placeholder | string | - | Hint shown while the field is empty. |
className | string | - | Extra classes. The field grows with its content from a 4rem minimum, so add min-h-32 for a taller one. |
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