Skip to content
bahtuiv0.6.0

<baht-input>

Single-line text/email field. Controlled: feed value, listen to baht-input.

Basic

<baht-input></baht-input>

<script>
  const el = document.querySelector('baht-input');
  el.field = {
    "order": 1,
    "type": "text",
    "key": "firstName",
    "label": "First name",
    "placeholder": "Somchai"
  };
  el.value = "";
</script>

Required + error

<baht-input required="true"></baht-input>

<script>
  const el = document.querySelector('baht-input');
  el.field = {
    "order": 1,
    "type": "text",
    "key": "email",
    "label": "Email"
  };
  el.value = "not-an-email";
  el.error = "Invalid email address";
</script>
NameTypeDefaultDescription
fieldJSFieldDescriptorField spec: { order, type, key, label?, placeholder?, options?, … }
valueJSunknownnullControlled value. Re-feed on every baht-input
disabledbooleanfalseDisable the control
readonlybooleanfalseRead-only
requiredbooleanfalseShow required mark
show-optionalbooleanfalseAppend the localized "(optional)" marker to the label when not required (set by <baht-form show-optional>).
errorJSstring | nullnullValidation message to display
debouncenumber | undefined150 (BahtFieldBase.defaultDebounce)Quiet time (ms) before typing reaches the host as baht-input. Blur flushes at once. 0 = every keystroke. <baht-form options.inputDebounce> sets it form-wide
EventdetailDescription
nameCustomEvent
baht-input{ key, value }Fired on every user edit