@trail-ui/react
Version:
53 lines (50 loc) • 1.9 kB
TypeScript
import * as react from 'react';
import { TextareaHTMLAttributes } from 'react';
import { InputVariantProps, SlotsToClasses, InputSlots } from '@trail-ui/theme';
import { TextareaHeightChangeMeta } from 'react-textarea-autosize';
interface TextAreaProps extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'color' | 'size'>, InputVariantProps {
/**
* Whether the textarea should automatically grow vertically to accomodate content.
* @default false
*/
disableAutosize?: boolean;
/**
* Minimum number of rows to show for textarea
* @default 3
*/
minRows?: number;
/**
* Maximum number of rows up to which the textarea can grow
* @default 8
*/
maxRows?: number;
/**
* Reuse previously computed measurements when computing height of textarea.
* @default false
*/
cacheMeasurements?: boolean;
/**
* Function invoked on textarea height change, with height as first argument.
* The second function argument is an object containing additional information that
* might be useful for custom behaviors. Current options include `{ rowHeight: number }`.
*
* @param height - The height of the textarea
* @param meta - Additional information about the height change
*/
onHeightChange?: (height: number, meta: TextareaHeightChangeMeta) => void;
/**
* Classes object to style the textarea and its children.
*/
classNames?: SlotsToClasses<InputSlots>;
/**
* Callback fired when the value is cleared.
* if you pass this prop, the clear button will be shown.
*/
onClear?: () => void;
'data-value'?: string;
}
/**
* A textarea allows a user to input mult-line text.
*/
declare const _TextArea: react.ForwardRefExoticComponent<TextAreaProps & react.RefAttributes<HTMLTextAreaElement>>;
export { _TextArea as TextArea, TextAreaProps };