Skip to content
iv-ui v0.3.0

Textarea

since 0.1.0

A multi-line text field with an optional count and error state.

import { Textarea } from '@elluzion/iv-ui';

Basic

A labelled textarea with helper text.

Source· svelte Show Hide
<script lang="ts">
	import { Textarea } from '@elluzion/iv-ui';

	let notes = $state('');
</script>

<div class="field-row">
	<Textarea
		label="Release notes"
		placeholder="What changed in this deploy?"
		bind:value={notes}
		helper="Markdown is supported."
	/>
</div>

<style>
	.field-row {
		width: 100%;
		max-width: 420px;
	}
</style>
  • Bind value for two-way state; oninput receives the native event.
  • showCount needs maxlength and renders the used and total characters.
  • resizable controls which axes the user may drag.

Character count

maxlength and showCount expose the remaining budget.

Source· svelte Show Hide
<script lang="ts">
	import { Textarea } from '@elluzion/iv-ui';

	let summary = $state('Tightened the focus ring and reduced the dialog entry by 40 ms.');
</script>

<div class="field-row">
	<Textarea label="Summary" maxlength={120} showCount bind:value={summary} />
</div>

<style>
	.field-row {
		width: 100%;
		max-width: 420px;
	}
</style>

States

Error, disabled, and read-only treatments.

Source· svelte Show Hide
<script lang="ts">
	import { Textarea } from '@elluzion/iv-ui';

	let description = $state('');
</script>

<div class="stack">
	<Textarea label="Description" bind:value={description} error="A description is required." />
	<Textarea label="Read only" value="Generated by the pipeline." readonly />
	<Textarea label="Disabled" value="Locked." disabled />
</div>

<style>
	.stack {
		display: flex;
		flex-direction: column;
		gap: var(--iv_spacing-lg);
		width: 100%;
		max-width: 420px;
	}
</style>
import { Textarea } from '@elluzion/iv-ui';

Props

14 props · 5 events · 0 snippets
PropTypeDefaultDescription
value bindablestring''Current value. Bind with bind:value.
placeholder string''Placeholder shown while the field is empty.
disabled booleanfalseDisables interaction and applies the disabled treatment.
readonly booleanfalsePrevents editing while keeping the value focusable and readable.
required booleanfalseMarks the field as required.
name string''Form field name submitted with the surrounding form.
id string''Element id. A generated id is used when omitted.
rows number4Visible number of text lines.
maxlength number—Maximum number of characters.
label string''Visible label for the control.
error string''Error message. Switches the control to the error treatment.
helper string''Helper text shown below the control.
resizable 'none' | 'vertical' | 'horizontal' | 'both''vertical'Which axes the user may resize.
showCount booleanfalseShows the character count when maxlength is set.

class, id, style, aria-*, and data-* are forwarded through rest props.

Events

EventHandler typeDescription
oninput(e: Event) => voidCalled on every keystroke with the native event.
onchange(e: Event) => voidCalled when the value changes; the new value is in event.detail.
onfocus(e: FocusEvent) => voidCalled when the control receives focus.
onblur(e: FocusEvent) => voidCalled when the control loses focus.
onkeydown(e: KeyboardEvent) => voidCalled on keydown with the native keyboard event.

The legacy on:name form is accepted for every event.

KeysAction
TabMoves focus into the textarea.
EnterInserts a new line.
  • The label is associated with the textarea through a generated id, or pass id.
  • Error text is linked through aria-describedby; the control gets aria-invalid.
  • The character count is part of the described-by content when showCount is on.
Class hooks
.iv-char-count.iv-disabled.iv-error-message.iv-footer-row.iv-has-error.iv-helper-message.iv-label.iv-message.iv-over-limit.iv-required-mark.iv-textarea-container.iv-textarea-wrapper
iv-ui
↑ ↓ navigate ↵ open esc close minisearch · 482 records