Skip to content

OTextarea ​

OTextarea renders a labelled multiline text control with accessible guidance, validation feedback, and optional decoration.

Usage ​

Step by step ​

  1. Import OTextarea from the ooko-ui/textarea public subpath.
  2. Bind application state with v-model and provide the required label.
  3. Add guidance, validation, and native textarea attributes directly on the component as needed.

Example ​

The rendered example and its source come from the same Vue single-file component.

Include the relevant context.

Interactive playground ​

Change the value, label, guidance, size, and textarea states. The preview updates immediately.

Helpful context appears here.

Props ​

PropTypeDefaultDescription
sizeOokoFormControlSize"md"Controls the textarea's form-control scale.
modelValuestringundefinedCurrent controlled value of the textarea.
labelstringundefinedVisible or visually hidden accessible label.
idstringundefinedNative textarea identifier. A hydration-safe identifier is generated when omitted.
namestringundefinedNative form field name and OForm validation key.
hintstringundefinedPersistent guidance displayed below the textarea.
errorstringundefinedControlled validation error displayed below the textarea.
validationOokoValidationBindingundefinedValidation binding created by useOokoValidation.
hideLabelbooleanfalseVisually hides the label while preserving its accessible name.
requiredbooleanfalseMarks the native textarea as required.
disabledbooleanfalseDisables the native textarea.
readonlybooleanfalseMakes the native textarea read-only.
iconComponentundefinedVue component rendered as a decorative textarea icon.
iconPositionOFieldIconPosition"leading"Places the icon before or after the textarea.

Events ​

EventPayloadDescription
update:modelValuestringEmits the current string value after native input.

Slots ​

SlotPropsDescription
iconnoneProvides custom decorative icon markup and overrides the icon prop.
TypeDefinition
OokoFormControlSizetype OokoFormControlSize = "sm" | "md";

CSS custom properties ​

Custom propertyDefaultDescription
--o-textarea-gapvar(--o-space-1)Sets the vertical space between field content.
--o-textarea-min-height7.5remSets the minimum editable area height.
--o-textarea-padding-inlinevar(--o-space-3)Sets the control shell inline padding.
--o-textarea-padding-blockvar(--o-space-2)Sets the control shell block padding.
--o-textarea-icon-gapvar(--o-space-2)Sets the space between the icon and textarea.
--o-textarea-icon-size1.25remSets the decorative icon size.
--o-textarea-border1px solid var(--o-border-color-control)Sets the border while preserving state colors by default.
--o-textarea-border-radiusvar(--o-radius-control)Sets the control corner radius.
--o-textarea-focus-width0.1875remSets the focus outline width.
--o-textarea-focus-stylesolidSets the focus outline style.
--o-textarea-focus-offset0.125remSets the distance between the control and focus outline.
--o-textarea-disabled-opacity0.5Sets the opacity of the complete disabled field.
--o-textarea-resizeverticalSets the native textarea resize behavior.

Override example ​

css
:root {
  --o-textarea-min-height: 10rem;
  --o-textarea-resize: both;
}

Accessibility ​

  • The label is connected to the native textarea through matching for and id values.
  • Hint, validation, and consumer-provided description identifiers are merged in aria-describedby.
  • Invalid textareas expose aria-invalid="true"; feedback is visible text announced through a polite live region.
  • Required, disabled, and read-only behavior uses native textarea attributes.
  • Decorative icons are hidden from assistive technologies and never replace the label.
  • Keyboard focus receives a visible shell outline, and forced-colors mode receives explicit state borders.
  • Generated identifiers use Vue's hydration-safe useId() API through OField.

Behavior and edge cases ​

  • OTextarea always emits a string and leaves trimming or normalization to the consumer.
  • Native attributes and listeners such as rows, maxlength, placeholder, wrap, aria-*, @input, and @change are forwarded to the textarea.
  • Consumer class and style attributes apply to the complete field root.
  • Native constraints are first displayed on blur, then refreshed during correction and on OForm submission.
  • Custom rules can be passed directly through validation or resolved from the nearest validation-enabled OForm by name. A direct binding takes precedence.
  • The controlled error prop takes precedence over native validation and must be cleared by the parent. It also takes presentation precedence over custom results. Reset does not clear it.
  • The icon slot overrides the icon prop. iconPosition has no visual effect without an icon.
  • App defaults may configure size and iconPosition; the resolved size is propagated to the internal OField.