'use client'
import { Textarea } from '@saas-ui/react'
export const TextareaBasic = () => {
  return <Textarea placeholder="Comment..." />
}
import { Textarea } from '@saas-ui/react/textarea'<Textarea placeholder="..." />Use the variant prop to change the appearance of the textarea.
import { Stack } from '@chakra-ui/react'
import { Textarea } from '@saas-ui/react'
export const TextareaWithVariants = () => {
  return (
    <Stack gap="4">
      <Textarea variant="outline" placeholder="outline" />
      <Textarea variant="subtle" placeholder="subtle" />
      <Textarea variant="flushed" placeholder="flushed" />
    </Stack>
  )
}
Use the size prop to change the size of the textarea.
import { Stack } from '@chakra-ui/react'
import { Textarea } from '@saas-ui/react'
export const TextareaWithSizes = () => {
  return (
    <Stack gap="4">
      <Textarea size="xs" placeholder="XSmall size" />
      <Textarea size="sm" placeholder="Small size" />
      <Textarea size="md" placeholder="Medium size" />
      <Textarea size="lg" placeholder="Large size" />
      <Textarea size="xl" placeholder="XLarge size" />
    </Stack>
  )
}
Pair the textarea with the Field component to add helper text.
Max 500 characters.
Max 500 characters.
'use client'
import { HStack } from '@chakra-ui/react'
import { Field, Textarea } from '@saas-ui/react'
export const TextareaWithHelperText = () => {
  return (
    <HStack gap="10" width="full">
      <Field.Root required>
        <Field.Label>Comment</Field.Label>
        <Textarea placeholder="Start typing..." variant="subtle" />
        <Field.HelperText>Max 500 characters.</Field.HelperText>
      </Field.Root>
      <Field.Root required>
        <Field.Label>Comment</Field.Label>
        <Textarea placeholder="Start typing..." variant="outline" />
        <Field.HelperText>Max 500 characters.</Field.HelperText>
      </Field.Root>
    </HStack>
  )
}
Pair the textarea with the Field component to add error text.
Field is required
Field is required
'use client'
import { HStack } from '@chakra-ui/react'
import { Field, Textarea } from '@saas-ui/react'
export const TextareaWithErrorText = () => {
  return (
    <HStack gap="10" width="full">
      <Field.Root invalid required>
        <Field.Label>Comment</Field.Label>
        <Textarea placeholder="Start typing..." variant="subtle" />
        <Field.ErrorText>Field is required</Field.ErrorText>
      </Field.Root>
      <Field.Root invalid required>
        <Field.Label>Comment</Field.Label>
        <Textarea placeholder="Start typing..." variant="outline" />
        <Field.ErrorText>Field is required</Field.ErrorText>
      </Field.Root>
    </HStack>
  )
}
Compose the textarea with the Field component to add a label, helper text, and
error text.
'use client'
import { HStack } from '@chakra-ui/react'
import { Field, Input } from '@saas-ui/react'
export const InputWithField = () => {
  return (
    <HStack gap="10" width="full">
      <Field.Root required>
        <Field.Label>Email</Field.Label>
        <Input placeholder="me@example.com" variant="subtle" />
      </Field.Root>
    </HStack>
  )
}
Here's an example of how to integrate the textarea with react-hook-form.
'use client'
import { Input, Stack } from '@chakra-ui/react'
import { Button, Field, Textarea } from '@saas-ui/react'
import { useForm } from 'react-hook-form'
interface FormValues {
  username: string
  bio: string
}
export const TextareaWithHookForm = () => {
  const {
    register,
    handleSubmit,
    formState: { errors },
  } = useForm<FormValues>()
  const onSubmit = handleSubmit((data) => console.log(data))
  return (
    <form onSubmit={onSubmit}>
      <Stack gap="4" align="flex-start" maxW="sm">
        <Field.Root required>
          <Field.Label>Username</Field.Label>
          <Input
            placeholder="@username"
            {...register('username', { required: 'Username is required' })}
          />
          <Field.ErrorText>{errors.username?.message}</Field.ErrorText>
          <Field.HelperText>This is your public display name.</Field.HelperText>
        </Field.Root>
        <Field.Root required>
          <Field.Label>Profile bio</Field.Label>
          <Textarea
            placeholder="I am ..."
            {...register('bio', { required: 'Bio is required' })}
          />
          <Field.ErrorText>{errors.bio?.message}</Field.ErrorText>
          <Field.HelperText>A short description of yourself</Field.HelperText>
        </Field.Root>
        <Button type="submit">Submit</Button>
      </Stack>
    </form>
  )
}
Use the resize prop to control the resize behavior of the textarea.
import { Stack } from '@chakra-ui/react'
import { Textarea } from '@saas-ui/react'
export const TextareaWithResize = () => {
  return (
    <Stack gap="4" maxWidth="250px">
      <Textarea resize="none" placeholder="Search the docs…" />
      <Textarea resize="vertical" placeholder="Search the docs…" />
      <Textarea resize="horizontal" placeholder="Search the docs…" />
      <Textarea resize="both" placeholder="Search the docs…" />
    </Stack>
  )
}
Here's an example of how to integrate the react-textarea-autosize package to
make the textarea autoresize.
'use client'
import { Textarea } from '@saas-ui/react'
export const TextareaWithAutoresize = () => {
  return <Textarea autoresize />
}
| Prop | Default | Type | 
|---|---|---|
| colorPalette  | 'gray' | 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink' | 'accent'The color palette of the component | 
| size  | 'md' | 'lg' | 'md' | 'sm' | 'xs'The size of the component | 
| variant  | 'outline' | 'outline' | 'filled' | 'flushed'The variant of the component |