WlNumberInput

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

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

The quantity needs approval.

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>