Tags Input
v0.0.10
v0.0.10StableHeadlessStatelessAccessibleJS-moduleApache-2.0
Installation
mix mishka.ui.gen.headless tags_input
Source
View Source
Parts & data attributes
The root carries chelekom-tags-input and data-disabled. Each part has a data-part value and a chelekom-tags-input__* class.
tagis one token. It holds its label, a remove button and, whennameis set, a hidden input with the tag.tag-labelis the text of the tag.removeis abuttonlabelled "Remove" plus the tag. It fireson_remove.inputis the draft field, with the id<id>-input.
disabled sets data-disabled on the root, disables the field and the remove buttons, and turns off click-to-focus.
Accessibility
A tags input has no formal WAI-ARIA pattern. It is a text field plus removable tokens. Enter adds the draft, and each remove button is a real button with its own label, so keyboard and screen reader users can remove a tag. Give the field a visible label. For suggestions, combine it with the headless Autocomplete.
Attributes
| Name | Type | Default | Values | Required | Description |
|---|---|---|---|---|---|
id
|
string
| — | — | Yes | Unique id; anchors the input for JS.focus |
name
|
string
| — | — | No | Name for the hidden list inputs — include the [] (e.g. "user[tags][]") |
tags
|
list
|
[]
| — | No | Current tags (list of strings) |
placeholder
|
string
| — | — | No | Placeholder for the draft input |
disabled
|
boolean
|
false
| — | No | Disable the control (also sets data-disabled) |
input_name
|
string
| — | — | No | Name for the draft input (bind to a form field so a reset clears it) |
input_value
|
string
| — | — | No | Value for the draft input |
on_add
|
any
| — | — | No | phx-keydown handler fired on Enter (when not using a wrapping form) |
on_remove
|
any
| — | — | No | phx-click for a tag's remove button (payload carries phx-value-tag) |
class
|
any
| — | — | No | Extra classes for the control |
tag_class
|
any
| — | — | No | Extra classes for each tag |
remove_class
|
any
| — | — | No | Extra classes for each remove button |
input_class
|
any
| — | — | No | Extra classes for the draft input |
tag_label_class
|
any
| — | — | No | — |
rest
|
global
| — | — | No | — |
Options
Each option takes one or more of its values, separated by commas.
| Option | Values |
|---|---|
--type
|
tags_input
|
--module
| A module name of your own |
What it generates
Functions
tags_input
Helpers
None
Generated with it
None
Command
mix mishka.ui.gen.headless tags_input