Skip to content
bahtuiv0.18.8

<baht-tags>

Creatable chip input. Type text + Enter or comma to add a chip; Backspace on an empty input removes the last one; pasting “a, b, c” adds three at once.

With suggestions

<baht-tags></baht-tags>

<script>
  const el = document.querySelector('baht-tags');
  el.field = {
    "order": 1,
    "type": "tags",
    "key": "labels",
    "label": "Labels",
    "placeholder": "Add a label…",
    "options": [
      {
        "key": "urgent",
        "label": "Urgent"
      },
      {
        "key": "billing",
        "label": "Billing"
      },
      {
        "key": "follow-up",
        "label": "Follow up"
      }
    ],
    "max_items": 6
  };
  el.value = [
    "japan-2026",
    "wedding"
  ];
</script>

allow_new: false — only suggestions can become chips

<baht-tags></baht-tags>

<script>
  const el = document.querySelector('baht-tags');
  el.field = {
    "order": 1,
    "type": "tags",
    "key": "category",
    "label": "Category",
    "allow_new": false,
    "options": [
      {
        "key": "food",
        "label": "Food"
      },
      {
        "key": "transport",
        "label": "Transport"
      },
      {
        "key": "shopping",
        "label": "Shopping"
      }
    ]
  };
  el.value = [];
</script>
NameTypeDefaultDescription
fieldJSFieldDescriptor—Field spec: { order, type, key, label?, placeholder?, options?, options_from?, max_items?, max_length?, allow_new? }
valueJSstring[]nullControlled value. Re-feed on every baht-input
disabledbooleanfalseDisable the control
readonlybooleanfalseRead-only
requiredbooleanfalseShow required mark; validated as "at least one tag"
show-optionalbooleanfalseAppend the localized "(optional)" marker to the label when not required (set by <baht-form show-optional>).
errorJSstring | nullnullValidation message to display
debouncenumber | undefined—Debounce for typed edits (ms); unset = BahtFieldBase.defaultDebounce.
EventdetailDescription
baht-input{ key, value: string[] }Fired on every chip add/remove — value is already normalised (trimmed, case-insensitive deduped, first spelling kept)
nameCustomEvent

required (at least one tag), max_items (chip count), max_length (per-tag character cap, default 32) and allow_new: false (chip must match a static options key, case-insensitive) are all enforced by the component interactively — with a brief inline hint on refusal, never a silent no-op — and re-checked by bank20baht-validator server-side, including per-row for a tags column inside a <baht-repeater>. options_from suggestions are trusted as typed server-side — the server cannot resolve the async fetcher, same as a dropdown’s dynamic options.

.baht-tags (wrapper) › .baht-tags-control (the bordered box, chips + input) › .baht-tag-chip / .baht-tag-chip-remove and .baht-tags-input. Suggestions reuse the shared .baht-listbox / .baht-listbox-option classes, the same ones <baht-select> and <baht-typeahead> use.