Autosize Textarea Form
spectrumui/autosize-textarea-formFreeComponent
component for the Autosize Textarea Form
Install it
npx shadcn@latest add https://ui.spectrumhq.in/r/autosize-textarea-form.jsonSource
1"use client";23import { zodResolver } from "@hookform/resolvers/zod";4import { useForm } from "react-hook-form";5import * as z from "zod";6import * as React from "react";7import {8 Form,9 FormControl,10 FormField,11 FormItem,12 FormLabel,13 FormMessage,14} from "@/components/ui/form";15import { toast } from "@/components/ui/use-toast";16import { AutosizeTextarea } from "@/components/ui/autosize-textarea";17import { LoadingButton } from "@/components/ui/loading-button";18import { useState } from "react";1920const FormSchema = z.object({21 bio: z.string().min(10, {22 message: "Bio must be at least 10 characters.",23 }),24});2526const DEFAULT_VALUE = {27 bio: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",28};2930const AutosizeTextareaForm = () => {31 const form = useForm<z.infer<typeof FormSchema>>({32 defaultValues: DEFAULT_VALUE,33 resolver: zodResolver(FormSchema),34 });3536 const [isClearBio, setIsClearBio] = useState(false);3738 const [loading, setLoading] = React.useState(false);3940 function onSubmit(data: z.infer<typeof FormSchema>) {41 setLoading(true);4243 setTimeout(() => {44 setLoading(false);45 toast({46 title: "Your submitted data",47 description: (48 <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">49 <code className="text-white">{JSON.stringify(data, null, 2)}</code>50 </pre>51 ),52 });53// … truncated
What it pulls in
Other registry items
Files it writes
More from spectrumui
All 182 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | spectrumui | Components | Free | no deps | |
| Alert demoalert-1 | spectrumui | Components | Free | 1 dep | |
| Alert 2alert-2 | spectrumui | Components | Free | no deps | |
| Alert 3alert-3 | spectrumui | Components | Free | 1 dep | |
| Alert 4alert-4 | spectrumui | Components | Free | 1 dep | |
| Animated Cardanimated-card | spectrumui | Components | Free | 1 dep · 2 files | |
| Animated Draweranimated-drawer | spectrumui | Components | Free | 4 deps | |
| Animated SVG Chartanimated-SVG-chart | spectrumui | Components | Free | 1 dep |
