page Textareacomponent { seo { title = "Textarea component" description = "Theme-aware, responsive textarea component." } view {
W WRNexusJS
forms component

Textarea

Theme-aware, responsive textarea component.

@wrnexus/ui 0.5.023 props0 slots5 events

Usage

Components are auto-discovered. Use the component directly in any .wrn view:

<Textarea
  size="default"
  color="primary"
  id="id"
  name="name"
  label="Textarea"
/>

Legacy mount name: data-component="Textarea".

Props and attributes

PropTypeRequirementDefault
sizestringOptional"default"
colorstringOptional"primary"
idstringOptional""
namestringOptional""
labelstringOptional"Textarea"
hiddenLabelbooleanOptionalfalse
placeholderstringOptional""
valuestringOptional""
variantstringOptional"normal"
iconstringOptional""
iconPositionstringOptional"start"
helperTextstringOptional""
cornerHintstringOptional""
errorstringOptional""
inlinebooleanOptionalfalse
rowsnumberOptional5
resizestringOptional"vertical"
readonlybooleanOptionalfalse
disabledbooleanOptionalfalse
requiredbooleanOptionalfalse
minlengthstringOptional""
maxlengthstringOptional""
classstringOptional""

Slots

This component does not declare a slot.

Events

  • input
  • change
  • focus
  • blur
  • invalid

Source contract

Installed source: components/Textarea.wrn

component Textarea {
  props {
    @event input = function
    @event change = function
    @event focus = function
    @event blur = function
    @event invalid = function
    size = "default"
    color = "primary"
    id = ""
    name = ""
    label = "Textarea"
    hiddenLabel = false
    placeholder = ""
    value = ""
    variant = "normal"
    icon = ""
    iconPosition = "start"
    helperText = ""
    cornerHint = ""
    error = ""
    inline = false
    rows = 5
    resize = "vertical"
    readonly = false
    disabled = false
    required = false
    minlength = ""
    maxlength = ""
    class = ""
  }
  functions {
    function emitField(nameEvent, sourceEvent) {
      sourceEvent.stopPropagation()
      $emit(nameEvent, { value: sourceEvent.currentTarget.value, name: name, sourceEvent: sourceEvent })
    }
    function handleInvalid(sourceEvent) {
      $emit("invalid", { value: sourceEvent.currentTarget.value, name: name, message: sourceEvent.currentTarget.validationMessage, sourceEvent: sourceEvent })
    }
  }
  view {
        <div {...attrs} class="wire-next wire-next--color-{color} wire-next--size-{size} wire-next--field wire-next--textarea {class}" data-variant="{variant}" data-inline="{inline}" data-floating="{variant === 'floating'}" data-invalid="{error ? 'true' : 'false'}">
        <div class="wire-next__field-heading">
        <label class="{hiddenLabel ? 'wire-next__sr-only' : ''}" for="{id || name}">{label}</label>{#if cornerHint}<span class="wire-next__field-hint">{cornerHint}</span>{/if}</div>
        <div class="wire-next__field-control" data-icon-position="{iconPosition}">
        {#if icon}<span class="{icon} wire-next__field-icon" aria-hidden="true">
        </span>{/if}
        <textarea id="{id || name}" name="{name}" placeholder="{variant === 'floating' ? ' ' : placeholder}" rows="{rows}" style="resize: {resize}" readonly="{readonly}" disabled="{disabled}" required="{required}" minlength="{minlength}" maxlength="{maxlength}" aria-invalid="{error ? 'true' : 'false'}" aria-describedby="{error ? (id || name) + '-error' : (helperText ? (id || name) + '-help' : '')}" @input="emitField('input', event)" @change="emitField('change', event)" @focus="emitField('focus', event)" @blur="emitField('blur', event)" @invalid="handleInvalid(event)">{value}</textarea>
        {#if variant === "floating"}<span class="wire-next__field-floating-label">{label}</span>{/if}
      </div>
      {#if helperText}<small id="{(id || name) + '-help'}" class="wire-next__field-help">{helperText}</small>{/if}
      <small id="{(id || name) + '-error'}" class="wire-next__field-error" data-error="{name}">{error}</small>
        </div>
    }
}
} }