Skip to content

InputTag Tag Input Box ​

Rules ​

Basic Example ​

js
const rule = {
    type:"elInputTag",
    title:"Tags",
    field:"tag",
    value: ['tag1', 'tag2', 'tag3']
}

Props Configuration Examples ​

Limit Tag Count ​

js
const rule = {
    type:"elInputTag",
    title:"Product Tags",
    field:"tags",
    value: ['Hot', 'New'],
    props: {
        max: 5,
        placeholder: "Enter tags (max 5)",
    },
}

Draggable Sorting ​

js
const rule = {
    type:"elInputTag",
    title:"Tag Sorting",
    field:"tags",
    value: ['Tag 1', 'Tag 2', 'Tag 3'],
    props: {
        draggable: true,
        placeholder: "Draggable sorting",
    },
}

Use Delimiter ​

js
const rule = {
    type:"elInputTag",
    title:"Keywords",
    field:"keywords",
    value: [],
    props: {
        delimiter: ',',
        placeholder: "Use comma to separate multiple keywords",
    },
}

Save on Blur ​

js
const rule = {
    type:"elInputTag",
    title:"Tags",
    field:"tags",
    value: [],
    props: {
        saveOnBlur: true,
        placeholder: "Auto-save on blur",
    },
}

Events Examples ​

Listen to Tag Changes ​

js
const rule = {
    type:"elInputTag",
    title:"Product Tags",
    field:"tags",
    value: [],
    props: {
        placeholder: "Enter tags",
    },
    on: {
        change: (value) => {
            console.log('Tags changed:', value);
        },
        'add-tag': (value) => {
            console.log('Tag added:', value);
        },
        'remove-tag': (value) => {
            console.log('Tag removed:', value);
        },
        blur: (event) => {
            console.log('Lost focus:', event);
        },
        focus: (event) => {
            console.log('Gained focus:', event);
        },
    },
}

Tag Count Limit Alert ​

js
const rule = {
    type:"elInputTag",
    title:"Product Tags",
    field:"tags",
    value: [],
    props: {
        max: 3,
        placeholder: "Maximum 3 tags",
    },
    inject: true,
    on: {
        'add-tag': ($inject, value) => {
            const currentTags = $inject.api.getValue('tags') || [];
            if (currentTags.length >= 3) {
                alert('Maximum 3 tags allowed!');
                // Remove the last tag
                currentTags.pop();
                $inject.api.setValue('tags', currentTags);
            }
        },
    },
}

Full configuration: Element_InputTag

value :Array

Props ​

NameDetailsTypeDefault
maxMaximum number of tags that can be addednumber—
tagTypeTag typeenuminfo
tagEffectTag effectenumlight
triggerKey to trigger tag inputenumEnter
draggableWhether tags can be draggedbooleanfalse
delimiterAdd tag when matching delimiterstring / regex—
sizeInput box sizeenum—
saveOnBlurWhether to save input value when input loses focusbooleantrue
clearableWhether to show clear buttonbooleanfalse
disabledWhether to disablebooleanfalse
validateEventWhether to trigger form validationbooleantrue
readonlyEquivalent to native readonly attributebooleanfalse
autofocusEquivalent to native autofocus attributebooleanfalse
idEquivalent to native input id attributestring—
tabindexEquivalent to native tabindex attributestring / number—
maxlengthEquivalent to native maxlength attributestring / number—
minlengthEquivalent to native minlength attributestring / number—
placeholderInput placeholder textstring—
autocompleteEquivalent to native autocomplete attributestringoff
ariaLabel a11yEquivalent to native aria-label attributestring—

Events ​

NameDetailsType
changeEvent triggered when bound value changesFunction
inputTriggered when Input value changesFunction
add-tagTriggered when tag is addedFunction
remove-tagTriggered when tag is removedFunction
focusTriggered when Input gains focusFunction
blurTriggered when Input loses focusFunction
clearTriggered when clear icon is clickedFunction

Slots ​

NameDetailsType
tagContent as tagobject
prefixInputTag header content—
suffixInputTag footer content—

FormCreate is an open-source project released under the MIT License. Free for personal and commercial use.