A controllable text area box.
<tk-text-area>
<span slot="label" class="l-block mb-2x">Labelled Text Area</span>
</tk-text-area>
Text areas are inputs for inputting text. They can be resized to allow for larger amount of text input than the tk-input
box.
<tk-text-area
max-length="5">
<span slot="label" class="l-block mb-2x">Maximum character length</span>
</tk-text-area>
The maxLength
prop can be provided to control the maximum number of characters that a tk-text-area
will accept.
<tk-text-area
placeholder="Example placeholder text">
<span slot="label" class="l-block mb-2x">Example placeholder text</span>
</tk-text-area>
Placeholders can be added to the tk-text-area
to give the user information, this disappears as soon as an input is entered.
<tk-text-area
is-filled="true"
value="Prefilled text">
<span slot="label" class="l-block mb-2x">Prefilled text</span>
</tk-text-area>
<hr>
<tk-text-area
error
is-filled="true"
value="Prefilled text">
<span slot="label" class="l-block mb-2x">Prefilled text in error state</span>
</tk-text-area>
<hr>
<tk-text-area
disabled
is-filled="true"
value="Prefilled text">
<span slot="label" class="l-block mb-2x">Prefilled text in disabled state</span>
</tk-text-area>
The value
prop can be used to prefill the input, or to make the tk-text-area
controlled.
<tk-text-area
rows="5">
<span slot="label" class="l-block mb-2x">Specified row count</span>
</tk-text-area>
The number of rows of text you wish the tx-text-area
to display can be specified. This will define the height of the tx-text-area
.
<tk-text-area
placeholder="Standard state">
<span slot="label" class="l-block mb-2x">Standard state</span>
</tk-text-area>
<hr>
<tk-text-area
error
placeholder="Error state">
<span slot="label" class="l-block mb-2x">Error state</span>
</tk-text-area>
<hr>
<tk-text-area
disabled
placeholder="Disabled state">
<span slot="label" class="l-block mb-2x">Disabled state</span>
</tk-text-area>
<hr>
<tk-text-area
readonly
placeholder="Readonly state">
<span slot="label" class="l-block mb-2x">Readonly state</span>
</tk-text-area>
The tk-text-area
can be in error, disabled, or readonly states.
<tk-text-area
placeholder="Resize Both">
<span slot="label" class="l-block mb-2x">Resize Both</span>
</tk-text-area>
<hr>
<tk-text-area
placeholder="Resize Vertical"
resize="vertical">
<span slot="label" class="l-block mb-2x">Resize Vertical</span>
</tk-text-area>
The tk-text-area
’s resize functionality can be changed. If defaults to being resized both horizontally and vertically, but can also be set to only be resized vertically.
<tk-text-area>
<span slot="hint" class="l-inline-flex l-v-center">
<tk-icon name="heart" size="xs" class="mr-1x" variant="filled"></tk-icon>
Enter text here
</span>
<span slot="label" class="l-block mb-2x">Text Area With Hint</span>
</tk-text-area>
<hr/>
<tk-text-area error value="Text value">
<span slot="hint" class="l-inline-flex l-v-center">
<tk-icon name="alert" size="xs" class="mr-1x" variant="filled"></tk-icon>
There was an error
</span>
<span slot="label" class="l-block mb-2x">Text Area With Error Hint</span>
</tk-text-area>
The tk-text-area
can render a hint containing any content injected into the
hint
slot, when supplied. When the error
prop is also true, the hint is
rendered in the error state, aria-invalid="true"
is added to the textarea
and the aria-errormessage
value of the textarea
is set to the id of the
tk-hint
.
<tk-text-area class="t-normal">
<tk-character-counter
count-down="true"
max-length="256"
slot="character-counter"
text=""
></tk-character-counter>
<span slot="label" class="l-block mb-2x">Text Area With Character Counter</span>
</tk-text-area>
<hr/>
<tk-text-area class="t-normal">
<span slot="hint" class="l-inline-flex l-v-center">
<tk-icon name="heart" size="xs" class="mr-1x" variant="filled"></tk-icon>
Enter text here
</span>
<tk-character-counter
count-down="true"
max-length="256"
slot="character-counter"
text=""
></tk-character-counter>
<span slot="label" class="l-block mb-2x">Text Area With Character Counter And Hint</span>
</tk-text-area>
The tk-text-area
renders any content injected into the character-counter
slot underneath and to the right-hand side of the textarea. As the name
suggests, the intended slot content is a tk-character-counter
component. The
counter will be inline with the hint, if one is provided.
<tk-text-area>
<span slot="label" class="mb-2x t-medium">Text Area With Medium Label</span>
</tk-text-area>
<hr/>
<tk-text-area>
<span slot="label" class="mb-2x t-large">Text Area With Large Label</span>
</tk-text-area>
If label
slot is provided, our typography utility classes can be used to change the sizing of the label to any size within that class. If no label size is set, medium is used as a default.
<tk-text-area
border="false"
placeholder="Example placeholder text">
<span slot="label" class="l-block mb-2x">Text Area With No Border</span>
</tk-text-area>
The tk-text-area
can be used with no surrounding borders. It should be used in a container (such as a modal) and accompanied with placeholder text and an aria-label to give the user additional guidance.
<tk-text-area prevent-paste="true">
<span slot="label" class="l-block mb-2x">Pasting from clipboard or dropping in text is disabled</span>
</tk-text-area>
When set to true, the user cannot paste text from the clipboard or drop text into the text area.
Inputs should always use the label
slot.
The component will then render a <label>
above the input and automatically make an association between the two.
Property | Attribute | Description | Type | Default |
---|---|---|---|---|
border |
border |
boolean |
true |
|
disabled |
disabled |
boolean |
false |
|
error |
error |
boolean |
false |
|
isFilled |
is-filled |
boolean |
false |
|
labelHidden |
label-hidden |
boolean |
false |
|
labelSize |
label-size |
string |
undefined |
|
labelText |
label-text |
string |
undefined |
|
maxLength |
max-length |
number |
undefined |
|
placeholder |
placeholder |
string |
undefined |
|
preventPaste |
prevent-paste |
Prevents the user from pasting text into the input when set to ’true'. | boolean |
false |
readonly |
readonly |
boolean |
false |
|
resize |
resize |
"both" | "vertical" |
'both' |
|
rows |
rows |
number |
undefined |
|
value |
value |
string |
'' |
Event | Description | Type |
---|---|---|
valueChanged |
CustomEvent<string> |
focusComponent() => Promise<void>
Type: Promise<void>