WlNumberInput
Limits
Full example
<div class="wl-stack" data-space="md">
<WlNumberInput
v-model="value"
:min="1"
:max="10"
aria-label="Quantity"
/>
</div>Formatting
Full example
<div class="wl-stack" data-space="md">
<WlNumberInput
v-model="value"
:min="1"
:max="10"
aria-label="Quantity"
/>
</div>States
Full example
<div class="wl-stack" data-space="md">
<WlNumberInput
v-model="value"
:min="1"
:max="10"
aria-label="Quantity"
/>
</div>Numbers, step and range
Compare sizes, integer and decimal steps, min/max limits, compact, invalid and disabled.
Sizes and a bounded range
Buttons and ↑/↓ apply step. Manual input commits on Enter or blur and is clamped to min/max.
Decimal input and states
Quantity: 3; budget: 20; price: 12.5.
Full example
<script setup lang="ts">
import { WlButton, WlField, WlNumberInput } from "legato-ui";
import { ref } from "vue";
const quantity = ref(3);
const budget = ref(20);
const price = ref(12.5);
</script>
<template>
<div class="wl-stack" data-space="xl" data-input-example="WlNumberInput">
<section class="wl-stack" data-space="md">
<h3 class="wl-text-subheading">{{ "Sizes and a bounded range" }}</h3>
<div class="wl-grid" data-space="lg">
<WlField
v-for="size in ['sm', 'md', 'lg'] as const"
:id="`docs-number-${size}`"
:key="size"
v-slot="{ id }"
:label="`${'Quantity, '}${size}`"
>
<WlNumberInput
:id="id"
v-model="quantity"
:size="size"
:min="1"
:max="10"
:aria-label="`${'Quantity, '}${size}`"
:decrement-label="`${'Decrease quantity, '}${size}`"
:increment-label="`${'Increase quantity, '}${size}`"
/>
</WlField>
<WlField id="docs-number-compact" v-slot="{ id }" label="Step 5, compact field"><WlNumberInput
:id="id"
v-model="budget"
:min="0"
:max="50"
:step="5"
density="compact"
aria-label="Budget"
decrement-label="Decrease budget"
increment-label="Increase budget"
/></WlField>
</div>
<p class="wl-text-small wl-text-muted">{{ "Buttons and ↑/↓ apply step. Manual input commits on Enter or blur and is clamped to min/max." }}</p>
</section>
<section class="wl-stack" data-space="md">
<h3 class="wl-text-subheading">{{ "Decimal input and states" }}</h3>
<div class="wl-grid" data-space="lg">
<WlField id="docs-number-price" v-slot="{ id }" label="Price, step 0.5"><WlNumberInput
:id="id"
v-model="price"
:min="0"
:max="100"
:step="0.5"
inputmode="decimal"
aria-label="Price"
decrement-label="Decrease price"
increment-label="Increase price"
/></WlField>
<WlField
id="docs-number-invalid"
v-slot="{ id, ariaDescribedby, invalid }"
label="Quantity with an error"
error="The quantity needs approval."
><WlNumberInput
:id="id"
v-model="quantity"
:min="1"
:max="10"
:invalid="invalid"
:aria-describedby="ariaDescribedby"
aria-label="Quantity with an error"
/></WlField>
<WlField id="docs-number-disabled" v-slot="{ id }" label="Disabled number input"><WlNumberInput
:id="id"
:model-value="5"
disabled
aria-label="Disabled quantity"
/></WlField>
</div>
<WlButton size="sm" @click="quantity = 3; budget = 20; price = 12.5">{{ "Reset numbers" }}</WlButton>
<p class="wl-text-small" role="status">{{
"Quantity:"
}} {{
quantity
}}{{
"; budget:"
}} {{
budget
}}{{
"; price:"
}} {{
price
}}.</p>
</section>
</div>
</template>Props
Types, accepted values and literal defaults come from the public manifest. Inherited settings name their source; “Not set” means no default is declared.
v-model: numberNumeric value (default 0).
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
min | number | 0 | Minimum. |
max | number | 99 | Maximum. |
step | number | 1 | Numeric step. |
size | WlSizeSm | "md" | Field size. |
density | WlDensity | "default" | Density. |
disabled | boolean | false | Disables the field. |
invalid | boolean | false | Error state. |
ariaLabel | string | Not set | Input aria-label. |
decrementLabel | string | Not set | Accessible decrement button name; falls back to WlConfig.locale.decrease (Decrease in English). |
incrementLabel | string | Not set | Accessible increment button name; falls back to WlConfig.locale.increase (Increase in English). |
format | boolean | Not set | Enable localized number parsing and display formatting. |
locale | string | Not set | Locale override for numeric display formatting. |
precision | number | Not set | Decimal precision used by numeric formatting. |
currency | string | Not set | ISO currency code used by number formatting. |
numberFormat | Intl.NumberFormatOptions | Not set | Intl.NumberFormat options for the displayed numeric value. |
prefix | string | Not set | Text displayed before the numeric value. |
suffix | string | Not set | Text displayed after the numeric value. |
pt | WlPt< | Not set | Attributes and callbacks for the component's documented pass-through sections. |
Events
| Event | Payload | When emitted |
|---|---|---|
update:modelValue | number | Emitted when the component requests a model change; the payload is the next value. |
Slots
| Slot | Type / values | Content |
|---|---|---|
prefix | prefix?(props: { value: number }): unknown; | Content before the numeric input; receives the current value. |
suffix | suffix?(props: { value: number }): unknown; | Content after the numeric input; receives the current value. |
Pass-through: pt
Sections WlNumberInput are listed below. Attributes merge in this order: createWlPt() WlConfig.ptpt instance. Class and style merge; the last supplied value takes priority for other attributes.
| Section | DOM | Purpose |
|---|---|---|
root | div.wl-stepper | Main element of the component. |
decrementButton | button.wl-stepper__btn | Button that decreases the numeric value. |
decrementIcon | span | Decorative decrement icon. |
prefix | span.wl-stepper__prefix | Text prefix shown beside the numeric input. |
input | input | Native input that receives focus and control attributes. |
suffix | span.wl-stepper__suffix | Text suffix shown beside the numeric input. |
incrementButton | button.wl-stepper__btn | Button that increases the numeric value. |
incrementIcon | span | Decorative increment icon. |
Sections refer to the component DOM. Dotted names identify a configuration group and its section; composite parts use their own pt groups. Global and local attributes merge, with class and style added together.
Keyboard and accessibility
- Give the field ariaLabel and distinct decrementLabel/incrementLabel, especially when the page has multiple steppers.
- The input has role=spinbutton and announces its current value, min and max. ArrowUp/ArrowDown and buttons change the value by step.
- Enter or blur commits the draft: commas are accepted for decimal input and values are clamped to min/max.
- The model is a number. Associate error text with the field through aria-describedby; invalid does not define range validation.
Keyboard and application responsibilities
Provide a meaningful accessible name and connect labels, hints and errors to the focusable element. Check the behavior with your own data and a screen reader.
WAI-ARIA Authoring PracticesChanges are emitted through v-model. After selection, cancellation and reset, labels and states must remain clear.
In your application, check keyboard controls, zoom and focus visibility. State labels and required information must be readable in every theme.