# `LedgerUI.Components.TagsInput`
[🔗](https://github.com/devaction-labs/ledger_ui/blob/v0.2.0/lib/ledger_ui/components/tags_input.ex#L1)

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`.

# `tags_input`

## Attributes

* `id` (`:string`) - Defaults to `nil`.
* `name` (`:string`) - Defaults to `nil`.
* `value` (`:any`) - Defaults to `nil`.
* `field` (`Phoenix.HTML.FormField`) - Defaults to `nil`.
* `label` (`:string`) - Defaults to `nil`.
* `help` (`:string`) - Defaults to `nil`.
* `errors` (`:list`) - Defaults to `[]`.
* `placeholder` (`:string`) - Defaults to `nil`.
* `suggestions` (`:list`) - Defaults to `[]`.
* `options` (`:list`) - Defaults to `nil`.
* `selected_options` (`:list`) - Defaults to `[]`.
* `create` (`:boolean`) - Defaults to `true`.
* `on_search` (`:string`) - Defaults to `nil`.
* `debounce` (`:integer`) - Defaults to `300`.
* `removable` (`:boolean`) - Defaults to `false`.
* `clearable` (`:boolean`) - Defaults to `false`.
* `clear_label` (`:string`) - Defaults to `"Clear"`.
* `remove_label` (`:string`) - Defaults to `"Remove"`.
* `create_label` (`:string`) - Defaults to `"Add"`.
* `persist` (`:boolean`) - Defaults to `true`.
* `restore_on_backspace` (`:boolean`) - Defaults to `false`.
* `create_hint` (`:string`) - Defaults to `"Enter"`.
* `max` (`:integer`) - Defaults to `nil`.
* `counter` (`:boolean`) - Defaults to `true`.
* `limit_placeholder` (`:string`) - Defaults to `"Limit reached"`.
* `create_position` (`:string`) - Defaults to `"top"`. Must be one of `"top"`, or `"bottom"`.
* `compact` (`:boolean`) - Defaults to `false`.
* `no_results` (`:string`) - Defaults to `"No results found"`.
* `disabled` (`:boolean`) - Defaults to `false`.
* `target` (`:any`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["form"]`.
## Slots

* `item`
* `option`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
