Skip to content

OrigamNumberField ​

<OrigamNumberField> is the numeric input with increment/decrement controls. It extends the field mixin set with min, max, step, precision, holdDelay, holdRepeat, split-button mode, hide-controls mode, and compact mode. Both normal and compact modes fully support rules-based validation and display error messages when a rule fails.

Basic usage with v-model ​

vue
<script setup lang="ts">
import { ref } from 'vue'
const qty = ref<number | null>(1)
</script>

<template>
  <OrigamNumberField v-model="qty" label="Quantity" :min="0" :max="100" />
</template>

Min / max / step / precision ​

vue
<template>
  <OrigamNumberField label="Price" :min="0" :max="9999" :step="0.01" :precision="2" />
</template>

Split mode ​

vue
<template>
  <OrigamNumberField label="Counter" split />
</template>

Hide controls ​

vue
<template>
  <OrigamNumberField label="No buttons" hide-controls />
</template>

Custom icons ​

vue
<template>
  <OrigamNumberField
    label="Volume"
    increment-icon="mdi-volume-plus"
    decrement-icon="mdi-volume-minus"
  />
</template>

States (disabled / readonly / error) ​

vue
<template>
  <OrigamNumberField label="Disabled" disabled :model-value="5" />
  <OrigamNumberField label="Error"    :error="true" error-messages="Out of range" />
</template>

Compact mode with validation ​

The compact mode (compact prop) renders a minimal − value + control. It passes through the same rules, error, errorMessages, validateOn, maxErrors, and hideDetails props as the normal mode — error messages appear directly below the compact control.

vue
<script setup lang="ts">
import { ref } from 'vue'
const qty = ref<number | null>(0)
</script>

<template>
  <OrigamNumberField
    v-model="qty"
    compact
    label="Quantity"
    :min="1"
    :max="99"
    :rules="[(v) => v != null && v >= 1 || 'Min 1']"
  />
</template>

Accessibility ​

The value-bearing <input> (both compact and non-compact rendering) carries role="spinbutton" with aria-valuenow / aria-valuemin / aria-valuemax / aria-valuetext kept in sync with the current value and the min / max props.

The compact-mode decrement/increment buttons' aria-label is driven by two i18n-key props rather than a hardcoded string:

PropTypeDefaultDescription
decrementAriaLabelstring'origam.number_field.aria_label.decrement'i18n key for the compact decrement button
incrementAriaLabelstring'origam.number_field.aria_label.increment'i18n key for the compact increment button
vue
<template>
  <OrigamNumberField
    compact
    label="Quantity"
    decrement-aria-label="myApp.qty.decrement"
    increment-aria-label="myApp.qty.increment"
  />
</template>

Slots ​

SlotScopeDescription
increment{ canIncrease, onControlClick, onUpControlMousedown, onControlMouseup }Custom increment button
decrement{ canDecrease, onControlClick, onDownControlMousedown, onControlMouseup }Custom decrement button
labelILabelPropsCustom label
prepend—Outside field before
append—Outside field after
prependInner—Inside field before
appendInner—Inside field after
field{ id, isDisabled, isDirty, isValid, isReadonly }Replace <input>

Emits ​

EventPayloadDescription
update:modelValuenumber | nullValue changed
update:focusedbooleanFocus state changed (own useFocus(props) call)
incrementnumber | nullIncrement button pressed
decrementnumber | nullDecrement button pressed
click:clearMouseEventClear button clicked
click:controlMouseEventControl area clicked
mousedown:controlMouseEventMousedown on the control area
click:prependMouseEventOuter prepend area clicked
click:appendMouseEventOuter append area clicked
click:prependInnerMouseEventInner prepend adornment clicked
click:appendInnerMouseEventInner append adornment clicked

focus and blur are not component emits — INumberFieldEmits does not declare them. They reach the consumer as plain DOM events, relayed by Vue's attribute fallthrough: @focus / @blur bound on <origam-number-field> work the normal HTML way, they just aren't part of the typed emits contract.

Design tokens ​

CSS variableDefaultDescription
--origam-number-field---control-width36pxInc/dec button width
--origam-field---border-colorsemantic borderOutline color
--origam-number-field--compact---gap8pxGap between compact buttons and input
--origam-number-field--compact__input---width3emWidth of the compact value input