DevactionUI.Pillbox (devaction_ui v0.1.0)

Copy Markdown View Source

A field of removable pills, for labels, e-mails, stacks: type and press Enter (or a comma) to add one, Backspace on an empty field removes the last, the × on a pill removes that one. Each pill is a hidden input named name[], so the form submits the list as it stands; the hook fires input on the box so phx-change hears every change. The browser owns the pills after mount (phx-update="ignore"): give it a new id to reset it from the server.

Summary

Functions

pillbox(assigns)

Attributes

  • id (:string) (required)
  • name (:string) (required) - the field name; the values are sent as name[].
  • values (:list) - Defaults to [].
  • label (:string) (required) - what the field is, for assistive technology.
  • placeholder (:string) - Defaults to nil.
  • remove_label (:string) (required) - "Remove", for the × of each pill.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • remove_icon - replaces the typographic × that removes a pill.