df-input Component
The df-input component provides a versatile text input field that integrates with both Vuetify and DynamicForms. It supports various input types including text, email, password, URL, and number.
Basic Usage
Below is an example of the df-input component with different text input types:
Basic Text Input Examples
Text
Field value:
Field validity:
Invalid
Validation errors:
- { "text": "Length must be between **3** and **50**", "textType": "md", "classes": "" }
Number Input
The df-input component provides specialized handling for number inputs, automatically switching to Vuetify's v-number-input component:
Number Input Example
Total: $10.99
Current Values:
Quantity: 1
Valid
Price: 10.99
Valid
Features
- Integration with
@dynamicforms/vue-formsfor state management and validation - Support for multiple input types: text, email, password, URL, and number
- Automatic use of specialized Vuetify number input for numerical fields
Props
In addition to common props from InputBase, this component supports:
| Prop | Type | Default | Description |
|---|---|---|---|
| inputType | 'text' | 'password' | 'email' | 'url' | 'number' | 'text' | Input type |
| min | number | undefined | Minimum value (for number inputs) |
| max | number | undefined | Maximum value (for number inputs) |
| step | number | undefined | Step value (for number inputs) |
| precision | number | undefined | Decimal precision (for number inputs) |
Inherited Props
This component inherits all common props from InputBase, including:
control- DynamicForms field objectmodelValue- The input value (v-model)label- Input labelhint- Hint text- And more...
Number Input Handling
When inputType is set to 'number', the component:
- Applies min, max, and step controls
- Validates for proper numeric format
The number input supports:
- Integer and decimal values
- Step controls for incrementing/decrementing
- Precision control for decimal places
- Min/max value restrictions
Events
This component emits all common events from InputBase:
update:modelValue- When the input value changes
Examples
Text Input
vue
<template>
<df-input
v-model="username"
label="Username"
hint="Enter your username"
:min-length="3"
:max-length="20"
pattern="^[a-zA-Z0-9_]+$"
/>
</template>
<script setup>
import { ref } from 'vue';
import { DfInput } from '@dynamicforms/vuetify-inputs';
const username = ref('');
</script>Number Input with DynamicForms
vue
<template>
<df-input
:control="form.fields.quantity"
input-type="number"
label="Quantity"
hint="Enter the desired quantity"
:min="1"
:max="100"
:step="1"
:precision="0"
/>
</template>
<script setup>
import { Group, Field } from '@dynamicforms/vue-forms';
import { DfInput } from '@dynamicforms/vuetify-inputs';
const form = new Group({
quantity: Field.create({ value: 1 }),
});
</script>