EN
Getting started
64 · Forms

Tag input

acun:tag-input provides free-form or list-based tag entry. Suggestions are matched case-insensitively, following Turkish letter rules. To let users pick one or more values from a long list, use acun:combobox on the Combobox page.

PRO acun:tag-input
01

Tag input

Type text and turn it into a tag with Enter or a comma; Backspace in the empty box deletes the last tag. The same tag is not added twice. Initial tags are given as an array with value.

LIVE EXAMPLE
<acun:tag-input name="tags" label="Tags" :value="['priority', 'wholesale']" />
PropValues
valueInitial tags (array)
placeholderType and press Enter
02

Choosing from a list, with a limit

When suggestions is given, only values from this list can be added, and up to six suggestions are shown while typing. max limits the number of tags that can be added.

LIVE EXAMPLE
<acun:tag-input name="categories" label="Categories" :suggestions="['Electronics', 'Clothing', 'Books', 'Home & living', 'Sports']" :value="['Electronics']" :max="3" />
PropValues
suggestionsAllowed values
maxMaximum number of tags
03

Disabled

disabled locks the component and shows it with a gray background: you cannot type in the box and the tags' remove buttons are hidden. In a classic form, the hidden fields are disabled too, so no value is submitted.

LIVE EXAMPLE
<acun:tag-input name="locked_tags" label="Tags" :value="['priority', 'wholesale']" disabled />
PropValues
disabledtrue | false (default false)
04

With Alpine

On Alpine pages the component binds to an outside array with x-model; as tags are added the array updates, and as the array changes the component updates. Other attributes such as class and data-* are added to the component's outer container.

LIVE EXAMPLE
<div x-data="{ tags: ['priority'] }" class="space-y-2">
    <acun:tag-input x-model="tags" label="Tags" />
    <p class="text-sm text-gray-600 dark:text-zinc-400">Tags: <span x-text="tags.join(', ')"></span></p>
</div>
PropValues
x-modelArray
classAdded to the outer container
05

In a form and with Livewire

In a classic form, each tag is submitted with a hidden field named name[]. When wire:model is given, the array is written directly to the Livewire property; hidden fields are still added with the property's name, so acun:form dirty-check and acun:form-actions see tag changes. When a tag is added or removed, the component dispatches a change event; text typed in the box does not count as a change. The component does not show validation errors itself; add them with @error if needed.

BLADE
<acun:tag-input wire:model="tags" label="Tags" :suggestions="$tagOptions" />
@error('tags')
    <p class="text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
@enderror
PropValues
wire:modelArray
changeWhen a tag is added or removed (bubbles)
API

Props and slots

The values the component accepts.

PropDefaultDescription
labelnullLabel above
value[]Initial tags
placeholderType and press EnterText in the empty box
suggestions[]If given, only values from this list can be chosen
maxnullMaximum number of tags
disabledfalseTurns off typing and removing; hidden fields are not submitted
wire:model / x-model — Livewire or Alpine binding (array)
Slots: name and id go to the field (and the hidden fields); other attributes such as class and data-* are added to the component's outer container.
Acun UI · Tag inputDetailed usage and examples