Skip to content

OrigamTextareaField ​

<OrigamTextareaField> is the multiline text input. It extends <OrigamTextField> with auto-grow, manual row control, resize suppression, and a persistent-clear button on top of the standard field mixin set.

Basic usage with v-model ​

vue
<script setup lang="ts">
import { ref } from 'vue'
const bio = ref('')
</script>

<template>
  <OrigamTextareaField v-model="bio" label="Bio" />
</template>

Rows & max rows ​

vue
<template>
  <OrigamTextareaField label="Short"     :rows="3" />
  <OrigamTextareaField label="Auto-grow" auto-grow :max-rows="8" />
</template>

No resize ​

vue
<template>
  <OrigamTextareaField label="Fixed"  no-resize />
</template>

Counter ​

vue
<template>
  <OrigamTextareaField label="Message" :counter="500" />
</template>

Prefix & suffix ​

vue
<template>
  <OrigamTextareaField label="Note" prefix=">" suffix="..." />
</template>

States (disabled / readonly / error) ​

vue
<template>
  <OrigamTextareaField label="Disabled" disabled />
  <OrigamTextareaField label="Readonly" readonly model-value="Cannot edit" />
  <OrigamTextareaField label="Error"    :error="true" error-messages="Too long" />
</template>

Slots ​

SlotScopeDescription
defaultfield propsFull body override
labelILabelPropsCustom label
floatingLabelILabelPropsCustom floating label
prefix—Before textarea
suffix—After textarea
prependInner—Inside field before
appendInner—Inside field after
prepend—Outside field before
append—Outside field after
loader—Loading indicator
counter{ counter, max, value }Custom counter
field{ id, isDisabled, isDirty, isValid, isReadonly }Replace <textarea>

Emits ​

EventPayloadDescription
update:modelValuestringValue changed
update:heightnumberAuto-grow height updated
focusFocusEventInput focused
blurFocusEventInput blurred
click:clearMouseEventClear button clicked
click:controlMouseEventControl area clicked
mousedown:controlMouseEventMousedown on control
format(command, value?)Rich-text command applied (toolbar click or keyboard shortcut).

Rich-text mode ​

Set mode="rich" to swap the underlying <textarea> for a lightweight in-house editor based on contenteditable. The editor ships with no external dependency (no TipTap, ProseMirror, Quill, …) — bundle cost is roughly 5 KB gz instead of the 150–300 KB that a full-featured editor brings.

vue
<script setup lang="ts">
import { ref } from 'vue'
const html = ref('<p>Start with some <strong>bold</strong></p>')
</script>

<template>
  <OrigamTextareaField
      v-model="html"
      mode="rich"
      output="html"
      label="Description"
  />
</template>

Output formats ​

outputv-model valueNotes
htmlsanitised HTMLDefault. Round-trips losslessly.
markdownCommonMark-flavoured textConverts on emit; the editor surface still keeps HTML internally.

When output="markdown", set the initial value as HTML — the editor seeds its DOM from the v-model verbatim. From then on, every emit serialises to Markdown.

Toolbar customisation ​

vue
<OrigamTextareaField
    v-model="html"
    mode="rich"
    :toolbar="['bold', 'italic', 'link', 'list-bullet']"
    toolbar-position="floating"
/>
CommandDefault keyboard shortcutIcon
boldCmd/Ctrl + Bmdi:format-bold
italicCmd/Ctrl + Imdi:format-italic
underlineCmd/Ctrl + Umdi:format-underline
linkCmd/Ctrl + Kmdi:link-variant
list-bulletCmd/Ctrl + Shift + 8mdi:format-list-bulleted
list-orderedCmd/Ctrl + Shift + 7mdi:format-list-numbered
heading—cycles H1 → H2 → H3 → P
code-inlineCmd/Ctrl + Emdi:code-tags
clear-format—mdi:format-clear

Pass :toolbar="false" to hide it entirely; the keyboard shortcuts keep working.

toolbarPosition accepts 'top' (default), 'bottom', 'floating' (sticky to the editor surface).

Slots ​

vue
<OrigamTextareaField v-model="html" mode="rich">
  <template #toolbar="{ format, isFormat }">
    <button :aria-pressed="isFormat('bold')" @click="format('bold')">B</button>
    <button :aria-pressed="isFormat('italic')" @click="format('italic')">I</button>
  </template>
</OrigamTextareaField>

Sanitisation ​

Every emit (typing, paste, setValue, external v-model write) passes through an in-house allowlist sanitiser.

Allowed tags: p, br, strong, b, em, i, u, a, ul, ol, li, h1, h2, h3, code.

Blocked tags (subtree removed): script, style, iframe, object, embed, form, svg, math, link, meta, base. Anything else is unwrapped (children promoted, parent dropped) — this preserves text content of disallowed wrappers.

Allowed attributes: href (on <a>, restricted to http: / https: / mailto: / tel: schemes plus relative URLs); class (whitelisted prefix origam-rich--* only). Every on* handler is stripped before per-tag filtering.

External links are hardened automatically with rel="noopener noreferrer nofollow" and target="_blank".

Accessibility ​

  • The toolbar wrapper carries role="toolbar" + aria-label (i18n key origam.textarea.rich.toolbar.aria-label).
  • Each command button is a real <button> with aria-label (i18n key per command) and aria-pressed="true|false" driven by the caret position.
  • The editing surface is role="textbox" aria-multiline="true" and exposes aria-disabled / aria-readonly when applicable.
  • aria-label falls back to the placeholder prop when set.

Limitations ​

The in-house implementation deliberately ships a minimal subset:

  • No structural undo / redo beyond the browser's native Ctrl+Z (which works because we use execCommand).
  • No tables, images or embed support.
  • No collaborative cursor / OT-CRDT integration.
  • No syntax-highlighting inside <code> blocks (use OrigamCode for that).
  • execCommand is technically deprecated by spec, but remains the pragmatic choice for a non-collaborative lightweight editor without a 100 KB+ dependency. We accept the tradeoff and will revisit if a major browser drops it.

Migration from TipTap / Quill ​

Drop the library, then map your stored value to either HTML or Markdown. Sanitise once on read (sanitizeHtml) if your stored content predates origam — the editor will then take over and keep everything inside the allowlist.

Typography ​

lineHeight sets --origam-textarea-field__rich-content---line-height, read directly by the rich-content SCSS.

fontWeight, fontSize and letterSpacing reach the visible surfaces by a different path than their own textarea-field__rich-content prefix (which none of them are read from): <OrigamTextareaField> forwards its own props to the nested <OrigamInput> AND <OrigamField> (which itself forwards again to <OrigamLabel>). fontWeight cascades from the <OrigamInput> root's own painted font-weight into the rich-mode contenteditable div (inherited CSS property, unblocked); fontWeight, fontSize and letterSpacing also all reach the field's visible label via the OrigamField → OrigamLabel forward (see the OrigamField doc). In the default plain mode (a native <textarea>), fontSize/fontWeight/ fontFamily do NOT inherit from <OrigamInput>'s root — form controls don't inherit font metrics from ancestors by default — so only the label and (in mode="rich") the rich content's fontWeight show the effect.

PropTypeDefaultDescription
fontSizeTFontSize—Reaches the visible label via the OrigamField → OrigamLabel forward.
fontWeightTFontWeight—Reaches the visible label (as above) AND, in mode="rich" only, the editable content via CSS inheritance from OrigamInput's root.
lineHeightTLineHeight—Sets --origam-textarea-field__rich-content---line-height directly.
letterSpacingTLetterSpacing—Reaches the visible label via the OrigamField → OrigamLabel forward.

fontFamily was removed from ITextareaFieldProps (issue #501) — no surface reads it, including the forwarded OrigamLabel (whose own fontFamily is likewise unread). fontFamily is a project-level setting configured once on OrigamApp.

Design tokens ​

CSS variableDefaultDescription
--origam-field---border-colorsemantic borderOutline color
--origam-field---bg-colorsurfaceBackground
--origam-textarea---min-height56pxMinimum textarea height
--origam-textarea-field__rich-toolbar---bg-colorsurface sunkenToolbar background
--origam-textarea-field__rich-toolbar---border-radiusradius.mdToolbar corner radius
--origam-textarea-field__rich-toolbar-btn-active---bg-coloraction primaryActive button background
--origam-textarea-field__rich-toolbar-btn-active---coloraction primary fgActive button foreground
--origam-textarea-field__rich-content---paddingspace.3Inner padding of the editable surface
--origam-textarea-field__rich-content---placeholder-colortext secondaryEmpty-state placeholder
--origam-textarea-field__rich-code-inline---bg-colorsurface sunkenInline <code> background
--origam-textarea-field__rich-link---coloraction primaryAnchor color
--origam-textarea-field__rich-heading---font-size-h1..h31.75/1.35/1.1remHeading sizes