Text
The text input type is used for general string input fields. It's the most common input type and supports various validation rules.
vue
<template>
<VsInputText v-model="textValue" />
</template>
<script setup>
import { ref } from 'vue'
import { VsInputText } from '@opengis/form'
const textValue = ref('');
</script>
Basic Text Input
vue
<VsInputText v-model="textValue" placeholder="Enter text" />
js
{
name: 'username',
type: 'text',
label: 'Username',
placeholder: 'Enter username',
rules: ['required']
}
Text with Validation
vue
<VsInputText v-model="textValue" placeholder="Enter email" />
js
{
name: 'email',
type: 'text',
label: 'Email Address',
placeholder: 'Enter your email',
rules: ['required', 'email']
}
Properties
Required Properties
- name (string): Unique identifier for the field
- type (string): Must be 'text'
- 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
- readonly (boolean): Whether the field is read-only
- maxlength (number): Maximum number of characters allowed
- minlength (number): Minimum number of characters required
- rules (array): Validation rules
- conditions (object): Conditional display logic
Schema Interface
typescript
interface TextSchemaItem {
name: string;
type: 'text';
label: string;
placeholder?: string;
disabled?: boolean;
readonly?: boolean;
maxlength?: number;
minlength?: number;
rules?: (string | object)[];
conditions?: Conditions | Conditions[];
}
Best Practices
- Use descriptive placeholders that guide users on what to enter
- Provide clear labels that explain the purpose of the field
- Use appropriate validation (required, email, min/max length)
- Set reasonable character limits to prevent abuse
- Use consistent styling across your application
- Consider accessibility with proper ARIA labels
- Provide helpful error messages for validation failures
- Use autocomplete attributes for common fields (name, email, etc.)
- Consider input masking for structured data (phone, SSN, etc.)
- Test with keyboard navigation for accessibility compliance