You are currently viewing outdated (<=3.x) Chameleon documentation on our old website. For version >=4.x, check out our new website.

Current release: 3.5.0 | hub

components

Textarea (code)

A Textarea is a TextField that allows the user to write over multiple lines.

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

Props

NameTypeDefaultRequiredDescription
actionNode--Contents displayed within the ActionLabel.
classNameString--Extend classNames.
colsNumber--The visible width of the text control, in average character widths. If it is specified, it must be a positive integer.
disabledBoolean--Visually and functionally disables the Textarea.
errorBoolean--Visually displayed as error text. Will add the necessary accessibility tags.
idString-trueNative HTML id attribute. Will also affect the label-id, and the message-id. For accessibility reasons.
labelNode-trueContents displayed within the PrimaryLabel.
labelHiddenBoolean--Visibly hide the label. (label is still required for a11y)
maxLengthNumber--The 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--Contents displayed beneath the input.
minLengthNumber--The minimum number of characters (UTF-16 code units) required that the user should enter.
nameString--Name of the form element.
onBlurFunction--Fires when the Textarea loses focus.
onChangeFunction--The event triggered, when the input value changes.
onFocusFunction--Fires when the Textarea receives focus.
optionalLabelString--Contents displayed within the OptionalLabel.
placeholderString--A 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--Indicates that the user cannot modify the value of the control
requiredBoolean--Specifies that the user must fill in a value before submitting a form.
rowsNumber--The number of visible text lines.
successBoolean--Visually displayed as success text. Will add the necessary accessibility tags.
valueString--The value of the input.
wrap'hard''soft''off'--Indicates how the control wraps text.

System Props

System Props

Next to the properties listed in the propstable, a collection of system props can be added to any component for further general styling and layouting purposes. These props vary per component.

To read more about the system, click here to check out its dedicated page.

Action

default: undefined

Adds an action or extra information to your item, mostly used for links.

Cols

default: undefined

This only affects the width of the textarea itself.

Disabled

default: undefined

Marking a Textarea as disabled, will disable all interaction with the element.

Error

default: undefined

To convey an error to the user, you can set the error prop to true.

LabelHidden

default: undefined

To meet accessibility requirements, every TextField should have an associated label. We do support the ability to visually hide the label when the Textarea's purpose is clear.

MaxLength

default: undefined

The 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. Make sure you don't overrule this programmatically.

Message

default: undefined

Give additional information to the user.

Message can be set to provide additional information.

MinLength

default: undefined

The minimum number of characters (UTF-16 code units) required that the user should enter. Make sure you still check this programmatically.

OptionalLabel (Required fields)

default: undefined

By default the Textarea is always required. To make a Textarea optional you can add the optionalLabel prop.

With Chameleon we take a specific approach where we encourage marking optional fields, not required. The majority of fields in a form are always required. Indicating that fields are required make users more fearful, it increases the risk of errors and reduces the form completion rate.

Placeholder

default: undefined

Placeholder text is displayed inside the field but is not always necessary. They should be written as examples helping users to understand the required input instead of instructions.

ReadOnly

default: undefined

It's not possible to write text inside the Textarea

Required

default: true

By default the Textarea is required. You can change this by providing an optionalLabel or passing false to the required prop. We encourage you to use the optionalLabel prop, this provides additional feedback to the user!

Rows

default: 2

To increase the default height of the Textarea, you can provide the number of initial rows.

Wrap

default: soft

Altering the wrap prop, will either not wrap the inputted text (off), or it will actually wrap the inputted text. The difference between hard and soft is that with hard, the value submitted will include the linebreaks.

Value

default: undefined

Use value for controlled Textfields.

© Copyright 2020 Mediahuis NV. All rights Reserved