Skip to main content

Textarea

Import

import { Textarea } from "@sparrowengg/twigs-react";

Usage

Result
Loading...
<Textarea rows="8" placeholder="Enter your description" />

Textarea error

Result
Loading...
<Textarea
  label="Enter your details"
  error="Not a valid description"
/>

Character count

<Textarea
showCount={true}
maxLength={10}
/>

Using maxLength and showCount props, you can show the character count of the Textarea field.

Result
Loading...
function CharacterCount() {
  const [value, setValue] = React.useState('');
  return (
    <Textarea
      label="Description"
      value={value}
      onChange={(e) => setValue(e.target.value)}
      showCount
      maxLength={10}
    />
  );
}

Variants

Result
Loading...
<Flex gap='12px' flexDirection='column'>
  <Textarea rows="4" placeholder='Default textarea variant' variant="default" />
  <Textarea rows="4" variant='filled' placeholder='Filled textarea variant' />
</Flex>

Props

PropertyDescriptionTypeDefault
variantstyle of textzreadefault filleddefault
onChangefunction
resizecontrol the textarea's resize abilityboth verical horizontal noneboth
disabledbooleanfalse
cssCustom styles for textareaobject
maxLengthMaximum allowed charactersnumber
rowsMaximum allowed rowsnumber
colsMaximum allowed colsnumber
errorBorderShow error border when there is errorbooleanfalse
requiredIndicatorShow required indicator next to textareaboolean, JSX Element
errorMessage for textarea errorstring
maxLengthMaximum allowed charactersnumber
showCountShow remaining allowed character lengthboolean