Skip to content

OInput ​

OInput renders a labelled single-line text input with accessible guidance and validation feedback.

Usage ​

Step by step ​

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

Example ​

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

We will not share your address.

Interactive playground ​

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

Helpful context appears here.

Props ​

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

Events ​

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

Slots ​

SlotPropsDescription
iconnoneProvides custom decorative icon markup and overrides the icon prop.
TypeDefinition
OInputTypetype OInputType = "email" | "password" | "search" | "tel" | "text" | "url";
OokoFormControlSizetype OokoFormControlSize = "sm" | "md";

CSS custom properties ​

Custom propertyDefaultDescription
--o-input-gapvar(--o-space-1)Sets the vertical space between field content.
--o-input-heightvar(--o-control-form-height-md)Sets the minimum input height.
--o-input-padding-inlinevar(--o-space-3)Sets the input's inline padding.
--o-input-icon-gapvar(--o-space-2)Sets the space between the icon and input.
--o-input-icon-size1.25remSets the decorative icon size.
--o-input-border1px solid var(--o-border-color-control)Sets the input border shorthand while preserving state colors by default.
--o-input-border-radiusvar(--o-radius-control)Sets the input corner radius.
--o-input-focus-width0.1875remSets the visible focus outline width.
--o-input-focus-stylesolidSets the visible focus outline style.
--o-input-focus-offset0.125remSets the distance between the input and its focus outline.
--o-input-disabled-opacity0.5Sets the opacity of the complete disabled field.

Override example ​

css
:root {
  --o-input-height: 3rem;
  --o-input-border-radius: var(--o-radius-round);
}

Accessibility ​

  • label is associated with the native input through matching for and id values.
  • hideLabel uses a visually hidden treatment and never removes the accessible name.
  • Hint and validation identifiers are merged with a consumer-provided aria-describedby value.
  • Invalid fields expose aria-invalid="true"; the inline error is announced through a polite live region and remains visible text rather than color alone.
  • Required, disabled, and read-only behavior uses native input attributes.
  • Decorative icons are hidden from assistive technologies and never replace the label.
  • Keyboard focus receives a visible outline, and forced-colors mode receives explicit borders.
  • Generated identifiers use Vue's hydration-safe useId() API.

Behavior and edge cases ​

  • The component accepts text-like input types only and always emits a string. Numeric, date, choice, and file controls require separate value contracts.
  • Native attributes and listeners such as autocomplete, inputmode, pattern, maxlength, placeholder, aria-*, @input, and @change are forwarded to the input.
  • Consumer class and style attributes apply to the complete field root instead of the inner input.
  • 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.
  • A placeholder does not replace the required label prop.
  • 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.