WlNumberInput

Type a number or use the buttons to increase or decrease it. The value stays within [min, max].
Components / Inputs v0.1.0

Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.

Settings

size

Field size.

density

Density.

min

Minimum.

max

Maximum.

step

Numeric step.

ariaLabel

Input aria-label.

decrementLabel

Accessible decrement button name; falls back to WlConfig.locale.decrease (Decrease in English).

incrementLabel

Accessible increment button name; falls back to WlConfig.locale.increase (Increase in English).

locale

Locale override for numeric display formatting.

precision
Not set

Decimal precision used by numeric formatting.

currency

ISO currency code used by number formatting.

prefix

Text displayed before the numeric value.

suffix

Text displayed after the numeric value.

Disables the field.

Error state.

Enable localized number parsing and display formatting.

Props numberFormat, pt, models, handlers and slots can be edited in the SFC. See their descriptions in API.

Example

Focus: outside the example · pointer: outside the example

Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.

Code for your application

Vue SFC · current settings
<script setup lang="ts">
import { WlNumberInput } from "legato-ui";
import { ref } from "vue";
const value = ref(3);
</script>

<template>
  <div class="wl-stack" data-space="md">
    <WlNumberInput
      v-model="value"
      :min="1"
      :max="10"
      aria-label="Quantity"
      
    />
  </div>
</template>

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

The quantity needs approval.

Quantity: 3; budget: 20; price: 12.5.

Vue SFC · additional 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-title">{{ "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-title">{{ "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>