A tag input: what is typed becomes a tag on Enter, Tab or a comma (pasting a comma separated
list creates several); tags are removed with Backspace or their remove button. Behaviour lives
in the LedgerUI.TagsInput hook (priv/static/ledger_ui/hooks/tags_input.js).
<.tags_input label="Tags" placeholder="Enter tags" field={@form[:tags]} removable />
<.tags_input name="tags" value={["awesome", "neat"]} removable restore_on_backspace />
<.tags_input name="tags" value="clear,items" clearable max={5} />value is a list of strings or a comma separated string. The tags are submitted as name[]
(plus an empty name[], so an empty list still reaches the server) through a hidden
<select multiple>, and each change fires a bubbling input event for phx-change.
suggestions (or options) are offered in the list while typing; with create={false} only
listed options can be chosen and on_search pushes %{"id" => id, "query" => text} to
target (or the LiveView), which answers by re-rendering options.
Summary
Functions
Attributes
id(:string) - Defaults tonil.name(:string) - Defaults tonil.value(:any) - Defaults tonil.field(Phoenix.HTML.FormField) - Defaults tonil.label(:string) - Defaults tonil.help(:string) - Defaults tonil.errors(:list) - Defaults to[].placeholder(:string) - Defaults tonil.suggestions(:list) - Defaults to[].options(:list) - Defaults tonil.selected_options(:list) - Defaults to[].create(:boolean) - Defaults totrue.on_search(:string) - Defaults tonil.debounce(:integer) - Defaults to300.removable(:boolean) - Defaults tofalse.clearable(:boolean) - Defaults tofalse.clear_label(:string) - Defaults to"Clear".remove_label(:string) - Defaults to"Remove".create_label(:string) - Defaults to"Add".persist(:boolean) - Defaults totrue.restore_on_backspace(:boolean) - Defaults tofalse.create_hint(:string) - Defaults to"Enter".max(:integer) - Defaults tonil.counter(:boolean) - Defaults totrue.limit_placeholder(:string) - Defaults to"Limit reached".create_position(:string) - Defaults to"top". Must be one of"top", or"bottom".compact(:boolean) - Defaults tofalse.no_results(:string) - Defaults to"No results found".disabled(:boolean) - Defaults tofalse.target(:any) - Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted. Supports all globals plus:
["form"].
Slots
itemoption