UNPKG

@carbon/react

Version:

React components for the Carbon Design System

120 lines (119 loc) 3.67 kB
/** * Copyright IBM Corp. 2016, 2025 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ import React, { type ReactNode } from 'react'; export interface TextAreaProps extends React.InputHTMLAttributes<HTMLTextAreaElement> { /** * Provide a custom className that is applied directly to the underlying * `<textarea>` node */ className?: string; /** * Specify the `cols` attribute for the underlying `<textarea>` node */ cols?: number; /** * **Experimental**: Provide a `decorator` component to be rendered inside the `TextArea` component */ decorator?: ReactNode; /** * Optionally provide the default value of the `<textarea>` */ defaultValue?: string | number; /** * Specify whether the control is disabled */ disabled?: boolean; /** * Specify whether to display the counter */ enableCounter?: boolean; /** * Provide text that is used alongside the control label for additional help */ helperText?: ReactNode; /** * Specify whether you want the underlying label to be visually hidden */ hideLabel?: boolean; /** * Provide a unique identifier for the control */ id?: string; /** * Specify whether the control is currently invalid */ invalid?: boolean; /** * Provide the text that is displayed when the control is in an invalid state */ invalidText?: ReactNode; /** * Provide the text that will be read by a screen reader when visiting this * control */ labelText: ReactNode; /** * @deprecated * `true` to use the light version. For use on $ui-01 backgrounds only. * Don't use this to make tile background color same as container background color. */ light?: boolean; /** * Max entity count allowed for the textarea. This is needed in order for enableCounter to display */ maxCount?: number; /** * Optionally provide an `onChange` handler that is called whenever `<textarea>` * is updated */ onChange?: (evt: React.ChangeEvent<HTMLTextAreaElement>) => void; /** * Optionally provide an `onClick` handler that is called whenever the * `<textarea>` is clicked */ onClick?: (evt: React.MouseEvent<HTMLTextAreaElement>) => void; /** * Optionally provide an `onKeyDown` handler that is called whenever `<textarea>` * is keyed */ onKeyDown?: (evt: React.KeyboardEvent<HTMLTextAreaElement>) => void; /** * Specify the placeholder attribute for the `<textarea>` */ placeholder?: string; /** * Whether the textarea should be read-only */ readOnly?: boolean; /** * Specify the rows attribute for the `<textarea>` */ rows?: number; /** * @deprecated please use `decorator` instead. * **Experimental**: Provide a `Slug` component to be rendered inside the `TextArea` component */ slug?: ReactNode; /** * Provide the current value of the `<textarea>` */ value?: string | number; /** * Specify whether the control is currently in warning state */ warn?: boolean; /** * Provide the text that is displayed when the control is in warning state */ warnText?: ReactNode; /** * Specify the method used for calculating the counter number */ counterMode?: 'character' | 'word'; } declare const TextArea: React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<HTMLTextAreaElement>>; export default TextArea;