Skip to content

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-forms for 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:

PropTypeDefaultDescription
inputType'text' | 'password' | 'email' | 'url' | 'number''text'Input type
minnumberundefinedMinimum value (for number inputs)
maxnumberundefinedMaximum value (for number inputs)
stepnumberundefinedStep value (for number inputs)
precisionnumberundefinedDecimal precision (for number inputs)

Inherited Props

This component inherits all common props from InputBase, including:

  • control - DynamicForms field object
  • modelValue - The input value (v-model)
  • label - Input label
  • hint - Hint text
  • And more...

Number Input Handling

When inputType is set to 'number', the component:

  1. Applies min, max, and step controls
  2. 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>

Released under the MIT License.