Number
The number input type is used for numeric input fields. It provides a specialized input for numbers with built-in browser validation and supports various validation rules for numeric constraints.
vue
<template>
<VsInputNumber v-model="numberValue" />
</template>
<script setup>
import { ref } from 'vue'
import { VsInputNumber } from '@opengis/form'
const numberValue = ref('');
</script>
Basic Number Input
vue
<VsInputNumber v-model="numberValue" />
js
{
name: 'age',
type: 'Number',
label: 'Age'
}
Properties
Required Properties
- name (string): Unique identifier for the field
- type (string): Must be 'number'
- label (string): Display label for the field
Optional Properties
- placeholder (string): Hint text shown when field is empty
- disabled (boolean): Whether the field is disabled
- layout (string): Layout type (default, horizontal)
- rules (array): Validation rules for the field
interface
typescript
interface NumberProps {
modelValue?: number | null;
placeholder?: string;
style?: object;
}
interface NumberSchemaItem {
name: string;
type: 'number';
label: string;
placeholder?: string;
disabled?: boolean;
rules?: (string | object)[];
conditions?: Conditions | Conditions[];
}
Best Practices
- Use appropriate placeholders that indicate the expected format or units
- Set reasonable validation ranges for your specific use case
- Consider decimal precision when dealing with currency or measurements
- Use descriptive labels that include units when relevant
- Validate for integer-only fields when whole numbers are required
- Set minimum and maximum bounds to prevent unrealistic values
- Consider negative values - allow them only when appropriate
- Use custom validation for complex numeric constraints