Forms & inputs
Layout
InputNumber
A number field with steppers and locale-aware formatting and parsing. Use it for quantities, prices and percentages.
Validating a form? vael-form wires this up with a schemaInstall
import { InputNumber } from 'vael-ui'Playground
decimal
end
undefined
Placement, behaviour and animation
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { InputNumber } from 'vael-ui'
const value = ref<number | null>(null)
</script>
<template>
<InputNumber
locale="en-US"
placeholder="Type here…"
v-model="value"
/>
</template>Motion New
InputNumber: its appearance and states.
<InputNumber
:motion="{ states: { invalid: { root: { scale: 1.04 } } } }"
/>| Name | Type | Description |
|---|---|---|
initialexit | rootinputincrementdecrement | Sets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate. |
states | invaliddisabledfocus | Sets values per part that hold while a state is on. An array is a set of keyframes that plays once as the state turns on, such as a shake on invalid. |
enterleave | (parts, context) => animation | Animates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted. |
springdurationeasing | { damping, response } | number | string | Times all of it: a spring, or a duration in ms with an easing. Never both. |
false | boolean | Turns its motion off, for an animation of your own on its exposed elements. |
Accessibility
Follows the Spinbutton pattern from the WAI-ARIA Authoring Practices Guide.
| Key | Action |
|---|---|
| ArrowUp | Adds one step, up to max. |
| ArrowDown | Subtracts one step, down to min. |
| Home | Sets the value to min, when min is set. |
| End | Sets the value to max, when max is set. |
| Enter | Clamps the typed value to min and max and formats it. |
- A text input with
role="spinbutton",aria-valuenow,aria-valueminandaria-valuemax. - The stepper buttons are out of the tab order (
tabindex="-1") and labeled “Increase” and “Decrease”; the arrow keys do the same job. - Keys do nothing while it is disabled or read-only. Leaving the field clamps and formats the value, like Enter.
- It is built on
Input, soFieldlabels it the same way.