Skip to main content

Textarea: React

The Textarea component represents a multi-line plain-text editing control, useful when you want to allow users to enter a sizeable amount of free-form text.

Installation

Before you can start using the @mediahuis/chameleon-react component, you’ll need to install it, for more information check: Getting started for developers.

With that done, you’re now ready to implement the component in your application.

import { Textarea } from '@mediahuis/chameleon-react';

export default function Example() {
return <Textarea id="textarea-1" label="Textarea Example" />;
}

Properties

PropertyTypeDefaultRequiredDescription
actionReactNode-NoContents displayed within the ActionLabel.
classNameString-NoAllows extending the class names of the component.
colsNumber-NoThe visible width of the text control, in average character widths. If it is specified, it must be a positive integer.
disabledBoolean-NoVisually and functionally disables the Textarea.
errorBoolean-NoVisually displayed as error text. Adds necessary accessibility tags.
idString-YesNative HTML id attribute. Also affects label-id and message-id for accessibility reasons.
labelReactNode-YesContents displayed within the PrimaryLabel.
labelHiddenBoolean-NoVisually hide the label. (label is still required for a11y)
maxLengthNumber-NoThe maximum number of characters (UTF-16 code units) that the user can enter. If this value isn't specified, the user can enter an unlimited number of characters.
messageString-NoContents displayed beneath the input.
minLengthNumber-NoThe minimum number of characters (UTF-16 code units) required that the user should enter.
nameString-NoName of the form element.
onBlurFocusEventHandler-NoFires when the Textarea loses focus.
onChangeChangeEventHandler-NoThe event triggered when the input value changes.
onFocusFocusEventHandler-NoFires when the Textarea receives focus.
optionalLabelString-NoContents displayed within the OptionalLabel.
placeholderString-NoA hint to the user of what can be entered in the control. Carriage returns or line-feeds within the placeholder text must be treated as line breaks when rendering the hint.
readOnlyBoolean-NoIndicates that the user cannot modify the value of the control.
requiredBoolean-NoSpecifies that the user must fill in a value before submitting a form.
rowsNumber-NoThe number of visible text lines.
successBoolean-NoVisually displayed as success text. Adds necessary accessibility tags.
valueString-NoThe value of the input.
wrap'hard' | 'soft' | 'off'-NoIndicates how the control wraps text.

required

Chameleon form inputs are required by default, with the required attribute automatically set. To mark a field as optional, pass the optionalLabel prop to remove the required attribute.