Netzo Logo

textarea

Displays a form textarea or a component that looks like a textarea.

shadcn/ui radix-ui Storybook Figma

Usage

After installation components can be imported and used directly.

import { Textarea } from 'netzo/components/textarea.tsx'

Examples

Working examples to copy-paste into projects under components/.

Default

import { Textarea } from "netzo/components/textarea.tsx";

export default () => {
  return <Textarea placeholder="Type your message here." />;
};

Disabled

import { Textarea } from "netzo/components/textarea.tsx";

export default () => {
  return <Textarea placeholder="Type your message here." disabled />;
};

Form

import { zodResolver } from "netzo/deps/@hookform/resolvers/zod.ts";
import { useForm } from "netzo/deps/react-hook-form.ts";
import { z } from "zod";
import { Button } from "netzo/components/button.tsx";
import { Checkbox } from "netzo/components/checkbox.tsx";
import {
  Form,
  FormControl,
  FormDescription,
  FormField,
  FormItem,
  FormLabel,
  FormMessage,
} from "netzo/components/form.tsx";
import {
  RadioGroup,
  RadioGroupItem,
} from "netzo/components/radio-group.tsx";
import { Switch } from "netzo/components/switch.tsx";
import { Textarea } from "netzo/components/textarea.tsx";
import { toast } from "netzo/components/use-toast.ts";

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 () => {
  const form = useForm<z.infer<typeof FormSchema>>({
    resolver: zodResolver(FormSchema),
  });

  function onSubmit(data: z.infer<typeof FormSchema>) {
    toast({
      title: "You submitted the following values:",
      description: (
        <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
          <code className="text-white">{JSON.stringify(data, null, 2)}</code>
        </pre>
      ),
    });
  }

  return (
    <Form {...form}>
      <form onSubmit={form.handleSubmit(onSubmit)} className="w-2/3 space-y-6">
        <FormField
          control={form.control}
          name="bio"
          render={({ field }) => (
            <FormItem>
              <FormLabel>Bio</FormLabel>
              <FormControl>
                <Textarea
                  placeholder="Tell us a little bit about yourself"
                  className="resize-none"
                  {...field}
                />
              </FormControl>
              <FormDescription>
                You can <span>@mention</span> other users and organizations.
              </FormDescription>
              <FormMessage />
            </FormItem>
          )}
        />
        <Button type="submit">Submit</Button>
      </form>
    </Form>
  );
};

With Button

import { Button } from "netzo/components/button.tsx";
import { Textarea } from "netzo/components/textarea.tsx";

export default () => {
  return (
    <div className="grid w-full gap-2">
      <Textarea placeholder="Type your message here." />
      <Button>Send message</Button>
    </div>
  );
};

With Label

import { Label } from "netzo/components/label.tsx";
import { Textarea } from "netzo/components/textarea.tsx";

export default () => {
  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

import { Label } from "netzo/components/label.tsx";
import { Textarea } from "netzo/components/textarea.tsx";

export default () => {
  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-muted-foreground">
        Your message will be copied to the support team.
      </p>
    </div>
  );
};