Skip to content

Textarea - Web Component

Browser support

Parameters

The Web component uses the <z-textarea> tag:

The parametrization of the component can be done with the following custom HTML params:

NameTypeDescription
configstring

The main parameter has two components following the pattern: <shape><?:size>.

  • shape: Establishes the styling of the input. Default value is line . Possible values are: shaped or line. ,
  • size: (optional) defines de size of the input. The default value is m, being omitted from the param. The possible values are: m or l.
labelstringLabel of the input
readonly
(optional)
booleanTransforms the input into an output
value
(optional)
stringValue of the model
disabled
(optional)
booleanBlocks the interaction with the input component.
required
(optional)
booleanMarks the input component as required.
name
(optional)
stringIdentification for the field inside the form
invalid
(optional)
booleanThe forced state for set the input as invalid
help-text
(optional)
stringThe forced message to be shown under the input
elastic
(optional)
booleanMakes the textarea auto-grow on typing

The events emitted from the component are:

NamePayloadDescription
onchangestringReturns the new value of the "value" attribute

config

The config parameter is used to set the shape of the input between lined and shaped. Being omitted will render the default line shape.

label

The label parameter is used to set the text label of the component. Make sure you always use it.

readonly

The readonly parameter is used to set the input in a read-only state. It's commonly used to display information.

value

The value parameter is used to set the text for the input.

disabled

The disabled parameter is used to block the interaction with the component. Not to be confused with readonly.

required

The required parameter is used to set the component as required.

name

The name parameter is used to set the name of the component. This is useful when the component is part of a form.

invalid

The invalid parameter is used to set the component as invalid.

help-text

The help-text parameter is used to provide additional assistance to the user.

max-length

The max-length parameter is used to set the maximum number of characters that the user can input. A counter will be displayed below the input.

elastic

The elastic parameter is used to set the textarea to grow and shrink automatically to fit the content.

Playground

Customization

HTML Examples

Imports
html
<link rel="stylesheet" href="/0.3.10/@zurich/web-components/styles.css" />
<script type="module" src="/0.3.10/@zurich/web-components/textarea.js"></script>
Code
html
<!-- Default -->
<z-textarea label="Textarea"></z-textarea>
<z-textarea label="Textarea" config="shaped"></z-textarea>

<!-- With value -->
<z-textarea label="Textarea" value="Some text"></z-textarea>
<z-textarea label="Textarea" value="Some text" config="shaped"></z-textarea>

<!-- Disabled -->
<z-textarea label="Textarea" disabled></z-textarea>
<z-textarea label="Textarea" disabled config="shaped"></z-textarea>

<!-- Readonly -->
<z-textarea label="Textarea" readonly value="Some text"></z-textarea>
<z-textarea label="Textarea" readonly value="Some text" config="shaped"></z-textarea>

<!-- With help text -->
<z-textarea label="Textarea" help-text="Help text"></z-textarea>
<z-textarea label="Textarea" help-text="Help text" config="shaped"></z-textarea>

<!-- With maxlength -->
<z-textarea label="Textarea" max-length="20"></z-textarea>
<z-textarea label="Textarea" max-length="20" config="shaped"></z-textarea>

<!-- Invalid -->
<z-textarea label="Textarea" help-text="Invalid input" invalid></z-textarea>
<z-textarea label="Textarea" help-text="Invalid input" invalid config="shaped"></z-textarea>