跳到主要内容

ITextArea

Custom textarea.

textareatextarea

Examples​

JSON configuration editor with syntax validation

const configEditor: ITextArea = {
value: JSON.stringify({
apiKey: "your-api-key",
endpoint: "https://api.example.com",
timeout: 5000
}, null, 2),
onChange: (value) => {
try {
JSON.parse(value);
return {
actions: [Actions.updateProps],
newProps: {
value,
hasError: false
}
};
} catch (error) {
return {
actions: [Actions.updateProps, Actions.showToast],
newProps: {
value,
hasError: true
},
toastProps: [{
title: "Please check your JSON syntax",
type: ToastType.error
}]
};
}
},
placeholder: "Enter JSON configuration...",
isJSONField: true,
enableCopy: true,
hasNumeration: true,
heightTextArea: 300,
fontSize: 14,
copyInfoText: true
}

Character-limited comment box with dynamic validation

const commentBox: ITextArea = {
value: "",
onChange: (value) => {
const hasError = value.length > 500;
return {
actions: [Actions.updateProps],
newProps: {
value,
hasError
}
};
},
placeholder: "Add your comment (max 500 characters)",
maxLength: 500,
heightTextArea: "120px",
isFullHeight: true,
heightScale: true,
fontSize: 16,
name: "comment",
tabIndex: 1
}

Properties​

PropertyTypeDescription
valuestringDefines the textarea value.
onChange(value: string) => void | IMessageSets a function which is triggered whenever the textarea is changed.
placeholderstringDefines the textarea placeholder.
isDisabledbooleanSpecifies whether the textarea is disabled.
isReadOnlybooleanSpecifies whether the textarea displays the read-only content.
hasErrorbooleanSpecifies whether to indicate that there is an error in the textarea.
maxLengthnumberDefines the maximum value length in the textarea.
namestringDefines the textarea HTML "name" property.
tabIndexnumberDefines the textarea HTML "tabindex" property.
fontSizenumberDefines the textarea font size.
heightTextAreastring | numberDefines the textarea height.
isJSONFieldbooleanSpecifies whether the textarea is prettified for JSON and the line numeration is added.
enableCopybooleanSpecifies whether the "Copy" icon is displayed in the textarea.
hasNumerationbooleanSpecifies whether the numeration is inserted into the textarea.
isFullHeightbooleanSpecifies whether the height of the textarea content is calculated depending on the number of lines.
heightScalebooleanSpecifies whether the textarea has a height scale.
copyInfoTextbooleanSpecifies whether the toast / information text will be displayed when copying.
classNamestringDefines the CSS class for styling the component. Can be used to override or extend the default component styles.