Textarea

The browser's own textarea in the Input's look, which grows with its text and can be dragged taller.

import { Label } from "@produkto/ui/Label";
import { Textarea } from "@produkto/ui/Textarea";

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-2">
    <Label htmlFor="textarea-preview">Label</Label>
    <Textarea id="textarea-preview" placeholder="Placeholder" />
  </div>
);

export default Example;

Usage

import { Textarea } from "@produkto/ui/Textarea";
<Textarea placeholder="Placeholder" />

Examples

Appearances

appearance paints the field on the kit's one scale: solid, the default, soft on the grey wash, outline with only its line, and transparent with neither until it is hovered.

import { Label } from "@produkto/ui/Label";
import { Textarea, type TextareaAppearance } from "@produkto/ui/Textarea";

const variants: { appearance: TextareaAppearance; label: string }[] = [
  { appearance: "solid", label: "Solid" },
  { appearance: "soft", label: "Soft" },
  { appearance: "outline", label: "Outline" },
  { appearance: "transparent", label: "Transparent" },
];

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-4">
    {variants.map((variant) => (
      <div className="flex flex-col gap-2" key={variant.appearance}>
        <Label htmlFor={`textarea-appearance-${variant.appearance}`}>
          {variant.label}
        </Label>
        <Textarea
          id={`textarea-appearance-${variant.appearance}`}
          placeholder="Placeholder"
          appearance={variant.appearance}
        />
      </div>
    ))}
  </div>
);

export default Example;

Sizes

size sets its padding and its least height: sm 56px, base 64px (the default) or lg 72px, its text lined up with an Input of the same size, the large one written at 16px on a phone.

import { Label } from "@produkto/ui/Label";
import { Textarea, type TextareaSize } from "@produkto/ui/Textarea";

const variants: { size: TextareaSize; label: string }[] = [
  { size: "sm", label: "Small" },
  { size: "base", label: "Base" },
  { size: "lg", label: "Large" },
];

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-4">
    {variants.map((variant) => (
      <div className="flex flex-col gap-2" key={variant.size}>
        <Label htmlFor={`textarea-size-${variant.size}`}>{variant.label}</Label>
        <Textarea
          id={`textarea-size-${variant.size}`}
          placeholder="Placeholder"
          size={variant.size}
        />
      </div>
    ))}
  </div>
);

export default Example;

Border radius

borderRadius sets its corners on the kit's one scale: none, xs 4px, sm 6px, base 8px (the default), lg 12px or xl 16px.

import { Label } from "@produkto/ui/Label";
import {
  Textarea,
  type TextareaBorderRadius,
} from "@produkto/ui/Textarea";

const variants: { borderRadius: TextareaBorderRadius; label: string }[] = [
  { borderRadius: "none", label: "None" },
  { borderRadius: "xs", label: "xs" },
  { borderRadius: "sm", label: "sm" },
  { borderRadius: "base", label: "base" },
  { borderRadius: "lg", label: "lg" },
  { borderRadius: "xl", label: "xl" },
];

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-4">
    {variants.map((variant) => (
      <div className="flex flex-col gap-2" key={variant.borderRadius}>
        <Label htmlFor={`textarea-radius-${variant.borderRadius}`}>
          {variant.label}
        </Label>
        <Textarea
          id={`textarea-radius-${variant.borderRadius}`}
          placeholder="Placeholder"
          borderRadius={variant.borderRadius}
        />
      </div>
    ))}
  </div>
);

export default Example;

Disabled

disabled dims the textarea and stops it taking text, beside one as it is by default.

import { Label } from "@produkto/ui/Label";
import { Textarea } from "@produkto/ui/Textarea";

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-4">
    <div className="flex flex-col gap-2">
      <Label htmlFor="textarea-enabled">Label</Label>
      <Textarea defaultValue="Content goes here." id="textarea-enabled" />
    </div>
    <div className="flex flex-col gap-2">
      <Label htmlFor="textarea-disabled">Label</Label>
      <Textarea
        defaultValue="Content goes here."
        disabled
        id="textarea-disabled"
      />
    </div>
  </div>
);

export default Example;

Invalid

error writes what is wrong under the textarea, turns its border to the destructive colour and describes it to screen readers, beside one without an error.

import { Label } from "@produkto/ui/Label";
import { Textarea } from "@produkto/ui/Textarea";

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-4">
    <div className="flex flex-col gap-2">
      <Label htmlFor="textarea-valid">Label</Label>
      <Textarea id="textarea-valid" placeholder="Placeholder" />
    </div>
    <div className="flex flex-col gap-2">
      <Label htmlFor="textarea-error">Label</Label>
      <Textarea
        error="Description"
        id="textarea-error"
        placeholder="Placeholder"
      />
    </div>
  </div>
);

export default Example;

API Reference

Textarea

TextareaProps · components/Textarea/Textarea.types.ts
PropTypeDefault
borderRadiusTextareaBorderRadius"none" | "xs" | "sm" | "base" | "lg" | "xl""base"
endReactNode-
appearanceTextareaAppearance"solid" | "soft" | "outline" | "transparent""solid"
sizeTextareaSize"sm" | "base" | "lg""base"
errorReactNode-

It also takes the props of <textarea>.