Textarea

February 2, 2026 ยท View on GitHub

Textarea is used for displaying custom textarea and beautified JSON object. It supports line numeration, JSON formatting, copy functionality, and responsive height adjustments.

Usage

import { Textarea } from "@docspace/ui-kit/components/textarea";
<Textarea
  placeholder="Add comment"
  onChange={(event) => alert(event.target.value)}
  value="value"
  isJSONField={false}
  onCopy={(text) => console.log("Copied:", text)}
/>

Properties

PropsTypeRequiredValuesDefaultDescription
classNamestring---Class name
wrapperClassNamestring---Class name for root div
idstring---Used as HTML id property
isDisabledbool--falseIndicates that the field cannot be used
isReadOnlybool--falseIndicates that the field is displaying read-only content
hasErrorbool--falseIndicates the input field has an error
namestring---Used as HTML name property
onChangefunc---Allow you to handle changing events of component
onCopyfunc---Callback when copy button is clicked
placeholderstring--" "Placeholder for Textarea
styleobj, array---Accepts css style
valuestring--""Value for Textarea
fontSizenumber--13Value for font-size
heightTextAreastring, number---Value for height text-area
isJSONFieldbool--falseIndicates that the field is displaying JSON object
copyInfoTextstring--Content was copied successfully!Indicates the text of toast/informational alarm
enableCopybool--falseEnables copy functionality with a button
hasNumerationbool--falseShows line numbers on the left side
heightScalebool--falseEnables height scaling to 67vh
isFullHeightbool--falseMakes textarea take full height of container
colorstring---Text color override
autoFocusbool--falseAutomatically focus the textarea on mount
areaSelectbool--falseAutomatically select all text on mount
tabIndexnumber---1Tab index for keyboard navigation

Features

  • RTL Support: Automatically handles right-to-left text direction
  • JSON Formatting: Beautifies JSON content when isJSONField is true
  • Copy Functionality: Provides a copy button when enableCopy is true (shows toast notification if copyInfoText is provided)
  • Line Numbers: Shows line numbers when hasNumeration is true
  • Adaptive Height: Supports various height modes (fixed, scaled, full)
  • Accessibility: Full keyboard navigation and screen reader support
  • Theme Support: Integrates with the application's theme system
  • Auto-resize: Automatically adjusts height based on content

Styling

The component uses SCSS modules for styling and supports theme customization through CSS variables. It includes:

  • Common input styles from the shared style system
  • Responsive height adjustments
  • RTL text direction support
  • Custom scrollbar styling
  • Focus and error states
  • Disabled state styling

Toast i18n Configuration

When using the copy functionality with copyInfoText, the component displays a success toast notification. The toast title is automatically localized if window.i18n is configured.

See i18n Setup for instructions on setting up window.i18n for localized toast titles.

// Example with copy notification
<Textarea
  enableCopy
  copyInfoText="Content was copied successfully!"
  value={jsonContent}
  isJSONField
/>