Skip to main content

Common Examples

import { Textarea } from "@servicetitan/anvil2";

function ExampleComponent() {
  return (
    <Textarea description="Description" label="Label" moreInfo="More info!" />
  );
}

Getting the textarea value

In a form

The Textarea component can be used in the same way that you would use an HTML textarea and label element.

Using state

Use the value prop to control the value of a Textarea using a state management strategy.

Using a ref

Use the value and ref props to control the value of a Textarea with a React ref and the ref.current.value.

Dynamic height

Use the autoHeight prop of the Textarea component to enable the element to grow to fit the text. Optionally, add maxRows and/or minRows to set height boundaries.

Show character counter

Use the maxLength and showCounter props to display a character counter below the textarea.
Last modified on January 23, 2026