Textarea
Displays a form textarea or a component that looks like a textarea.
import Textarea from '@dinui/react/textarea'
export default function TextareaDemo() { return <Textarea placeholder="Type your message here." />}Disabled
import Textarea from '@dinui/react/textarea'
export default function TextareaDisabledDemo() { return <Textarea placeholder="Type your message here." disabled />}With Label
import Label from '@dinui/react/label'import Textarea from '@dinui/react/textarea'
export default function TextareaWithLabelDemo() { return ( <div className="grid w-full gap-1.5"> <Label htmlFor="message">Your message</Label> <Textarea placeholder="Type your message here." id="message" /> </div> )}With Text
Your message will be copied to the support team.
import Label from '@dinui/react/label'import Textarea from '@dinui/react/textarea'
export default function TextareaWithTextDemo() { return ( <div className="grid w-full gap-1.5"> <Label htmlFor="message-2">Your Message</Label> <Textarea placeholder="Type your message here." id="message-2" /> <p className="text-sm text-fg-weaker">Your message will be copied to the support team.</p> </div> )}With Button
import Button from '@dinui/react/button'import Textarea from '@dinui/react/textarea'
export default function TextareaWithButtonDemo() { return ( <div className="grid w-full gap-2"> <Textarea placeholder="Type your message here." /> <Button>Send message</Button> </div> )}Form
'use client'
import Button from '@dinui/react/button'import Form, { useForm } from '@dinui/react/form'import Textarea from '@dinui/react/textarea'import { zodResolver } from '@hookform/resolvers/zod'import { z } from 'zod'
const FormSchema = z.object({ bio: z .string() .min(10, { message: 'Bio must be at least 10 characters.', }) .max(160, { message: 'Bio must not be longer than 30 characters.', }),})
export default function TextareaForm() { const form = useForm<z.infer<typeof FormSchema>>({ resolver: zodResolver(FormSchema), })
function onSubmit(data: z.infer<typeof FormSchema>) { alert(`You submitted the following values: ${JSON.stringify(data, null, 2)}`) }
return ( <Form form={form} onSubmit={form.handleSubmit(onSubmit)} className="w-2/3 space-y-6"> <Form.Field control={form.control} name="bio" render={({ field }) => ( <Form.Item> <Form.Label>Bio</Form.Label> <Form.Control> <Textarea placeholder="Tell us a little bit about yourself" className="resize-none" {...field} /> </Form.Control> <Form.Description> You can <span>@mention</span> other users and organizations. </Form.Description> <Form.ErrorMessage /> </Form.Item> )} />
<Button type="submit">Submit</Button> </Form> )}Installation
-
Follow Installation Guide
To enable DinUI functionality in your project, you will need to properly set up Tailwind and install the necessary dependencies. -
All done
You now can start using this component in your project.
-
Follow Installation Guide
To enable DinUI functionality in your project, you will need to properly set up Tailwind and install the necessary dependencies. -
Run the following command in your project
Terminal window npx @dinui/cli@latest add textareaTerminal window yarn dlx @dinui/cli@latest add textareaTerminal window pnpm dlx @dinui/cli@latest add textareaTerminal window bunx @dinui/cli@latest add textarea -
Update the import paths to match your project setup
-
All done
You now can start using this component in your project.
-
Follow Installation Guide
To enable DinUI functionality in your project, you will need to properly set up Tailwind and install the necessary dependencies. -
Install dependencies
Terminal window npm install tailwind-variantsTerminal window yarn add tailwind-variantsTerminal window pnpm add tailwind-variantsTerminal window bun add tailwind-variants -
Copy and paste the following code into your project
import { forwardRef } from 'react'import { tv } from 'tailwind-variants'const textarea = tv({slots: {root: ['flex min-h-[60px] w-full rounded-md border bg-transparent px-3 py-2','text-sm shadow-sm placeholder:text-fg-weaker','disabled:cursor-not-allowed disabled:opacity-50',],},})const Textarea = forwardRef<HTMLTextAreaElement, React.ComponentPropsWithoutRef<'textarea'>>((props, ref) => {const { root } = textarea()return <textarea {...props} ref={ref} className={root({ className: props.className })} />},)Textarea.displayName = 'Textarea'export default Textareaexport { textarea } -
Update the import paths to match your project setup
-
All done
You now can start using this component in your project.