跳到主要内容

ITextArea

View source on GitHub

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.
placeholder?stringDefines the textarea placeholder.
isDisabled?booleanSpecifies whether the textarea is disabled.
isReadOnly?booleanSpecifies whether the textarea displays the read-only content.
hasError?booleanSpecifies whether to indicate that there is an error in the textarea.
maxLength?numberDefines the maximum value length in the textarea.
name?stringDefines the textarea HTML "name" property.
tabIndex?numberDefines the textarea HTML "tabindex" property.
fontSize?numberDefines the textarea font size.
heightTextArea?string | numberDefines the textarea height.
isJSONField?booleanSpecifies whether the textarea is prettified for JSON and the line numeration is added.
enableCopy?booleanSpecifies whether the "Copy" icon is displayed in the textarea.
hasNumeration?booleanSpecifies whether the numeration is inserted into the textarea.
isFullHeight?booleanSpecifies whether the height of the textarea content is calculated depending on the number of lines.
heightScale?booleanSpecifies whether the textarea has a height scale.
copyInfoText?booleanSpecifies whether the toast / information text will be displayed when copying.
className?stringDefines the CSS class for styling the component. Can be used to override or extend the default component styles.