0.0.4

Combobox

A pure vanilla JS implementation of Zag JS Combobox Opens in a new window


Anatomy

The Combobox component consists of the following data-part

root label control title input clear-trigger trigger positioner content item
  • US Dollar
  • Euro
  • British Pound
  • Japanese Yen
  • Indian Rupee
<div class="combobox-js combobox" data-placeholder="Type or select currency">
                  <div data-part="root">
                  <label data-part="label">Your Currency</label>
                  <div data-part="control">
                  <input data-part="input">
                  <button data-part="clear-trigger">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M12 9.75 14.25 12m0 0 2.25 2.25M14.25 12l2.25-2.25M14.25 12 12 14.25m-2.58 4.92-6.374-6.375a1.125 1.125 0 0 1 0-1.59L9.42 4.83c.21-.211.497-.33.795-.33H19.5a2.25 2.25 0 0 1 2.25 2.25v10.5a2.25 2.25 0 0 1-2.25 2.25h-9.284c-.298 0-.585-.119-.795-.33Z"></path>
                  </svg>
                  </button>
                  <button data-part="trigger">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5"></path>
                  </svg>
                  </button>
                  </div>
                  <div data-part="positioner">
                  <ul data-part="content" class="scrollbar">
                  <li data-part="item" data-code="USD" data-label="US Dollar">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M12 6v12m-3-2.818.879.659c1.171.879 3.07.879 4.242 0 1.172-.879 1.172-2.303 0-3.182C13.536 12.219 12.768 12 12 12c-.725 0-1.45-.22-2.003-.659-1.106-.879-1.106-2.303 0-3.182s2.9-.879 4.006 0l.415.33M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  US Dollar
                  </li>
                  <li data-part="item" data-code="EURO" data-label="Euro">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M14.25 7.756a4.5 4.5 0 1 0 0 8.488M7.5 10.5h5.25m-5.25 3h5.25M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  Euro
                  </li>
                  <li data-part="item" data-code="GBP" data-label="British Pound">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M14.121 7.629A3 3 0 0 0 9.017 9.43c-.023.212-.002.425.028.636l.506 3.541a4.5 4.5 0 0 1-.43 2.65L9 16.5l1.539-.513a2.25 2.25 0 0 1 1.422 0l.655.218a2.25 2.25 0 0 0 1.718-.122L15 15.75M8.25 12H12m9 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  British Pound
                  </li>
                  <li data-part="item" data-code="YEN" data-label="Japanese Yen">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="m9 7.5 3 4.5m0 0 3-4.5M12 12v5.25M15 12H9m6 3H9m12-3a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  Japanese Yen
                  </li>
                  <li data-part="item" data-code="AL" data-label="Indian Rupee">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M15 8.25H9m6 3H9m3 6-3-3h1.5a3 3 0 1 0 0-6M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  Indian Rupee
                  </li>
                  </ul>
                  </div>
                  </div>
                  </div>

If you have a lot of data, you can also load the collection with a json file

You first need to add a inline script including the collection as well as the collection name

                  <script type="application/json" data-combobox="countries">
                      [
                      { "label": "France", "code": "FR" },
                      { "label": "Belgium", "code": "BE" },
                      { "label": "Germany", "code": "DE" },
                      { "label": "Italy", "code": "IT" },
                      { "label": "Spain", "code": "ES" },
                      { "label": "Portugal", "code": "PT" },
                      { "label": "Netherlands", "code": "NL" },
                      { "label": "Switzerland", "code": "CH" },
                      { "label": "Austria", "code": "AT" },
                      { "label": "Poland", "code": "PL" },
                      { "label": "Czech Republic", "code": "CZ" },
                      { "label": "Hungary", "code": "HU" },
                      { "label": "Greece", "code": "GR" }
                      ]
                      </script>
                  
              
<div class="combobox-js combobox" data-json="countries" data-placeholder="Type or select country">
                  <div data-part="root">
                  <label data-part="label">Your Country</label>
                  <div data-part="control">
                  <input data-part="input">
                  <button data-part="clear-trigger">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M12 9.75 14.25 12m0 0 2.25 2.25M14.25 12l2.25-2.25M14.25 12 12 14.25m-2.58 4.92-6.374-6.375a1.125 1.125 0 0 1 0-1.59L9.42 4.83c.21-.211.497-.33.795-.33H19.5a2.25 2.25 0 0 1 2.25 2.25v10.5a2.25 2.25 0 0 1-2.25 2.25h-9.284c-.298 0-.585-.119-.795-.33Z"></path>
                  </svg>
                  </button>
                  <button data-part="trigger">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5"></path>
                  </svg>
                  </button>
                  </div>
                  <div data-part="positioner">
                  <ul data-part="content" class="scrollbar">
                  </ul>
                  </div>
                  </div>
                  </div>

Data attributes

Each combobox can be set with different settings with the following data-attribute.

  • US Dollar
  • Euro
  • British Pound
  • Japanese Yen
  • Indian Rupee
<div class="combobox-js combobox" data-default-open="true" data-allow-custom-value="true" data-placeholder="Type or select currency">
                  <div data-part="root">
                  <label data-part="label">Your Currency</label>
                  <div data-part="control">
                  <input data-part="input">
                  <button data-part="clear-trigger">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M12 9.75 14.25 12m0 0 2.25 2.25M14.25 12l2.25-2.25M14.25 12 12 14.25m-2.58 4.92-6.374-6.375a1.125 1.125 0 0 1 0-1.59L9.42 4.83c.21-.211.497-.33.795-.33H19.5a2.25 2.25 0 0 1 2.25 2.25v10.5a2.25 2.25 0 0 1-2.25 2.25h-9.284c-.298 0-.585-.119-.795-.33Z"></path>
                  </svg>
                  </button>
                  <button data-part="trigger">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5"></path>
                  </svg>
                  </button>
                  </div>
                  <div data-part="positioner">
                  <ul data-part="content" class="scrollbar">
                  <li data-part="item" data-code="USD" data-label="US Dollar">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M12 6v12m-3-2.818.879.659c1.171.879 3.07.879 4.242 0 1.172-.879 1.172-2.303 0-3.182C13.536 12.219 12.768 12 12 12c-.725 0-1.45-.22-2.003-.659-1.106-.879-1.106-2.303 0-3.182s2.9-.879 4.006 0l.415.33M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  US Dollar
                  </li>
                  <li data-part="item" data-code="EURO" data-label="Euro">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M14.25 7.756a4.5 4.5 0 1 0 0 8.488M7.5 10.5h5.25m-5.25 3h5.25M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  Euro
                  </li>
                  <li data-part="item" data-code="GBP" data-label="British Pound">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M14.121 7.629A3 3 0 0 0 9.017 9.43c-.023.212-.002.425.028.636l.506 3.541a4.5 4.5 0 0 1-.43 2.65L9 16.5l1.539-.513a2.25 2.25 0 0 1 1.422 0l.655.218a2.25 2.25 0 0 0 1.718-.122L15 15.75M8.25 12H12m9 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  British Pound
                  </li>
                  <li data-part="item" data-code="YEN" data-label="Japanese Yen">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="m9 7.5 3 4.5m0 0 3-4.5M12 12v5.25M15 12H9m6 3H9m12-3a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  Japanese Yen
                  </li>
                  <li data-part="item" data-code="AL" data-label="Indian Rupee">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M15 8.25H9m6 3H9m3 6-3-3h1.5a3 3 0 1 0 0-6M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  Indian Rupee
                  </li>
                  </ul>
                  </div>
                  </div>
                  </div>
Data attribute Type / Options Description
id string The unique id of the component. Default generated if none is provided
data-json string The name of the collection loaded as a inline script
data-open boolean The controlled open state of the combobox
data-default-open boolean The initial open state of the combobox when rendered. Use when you don't need to control the open state of the combobox.
data-input-value string The controlled value of the combobox's input
data-default-input-value string The initial value of the combobox's input when rendered. Use when you don't need to control the value of the combobox's input.
data-dir ltr | rtl The orientation of the combobox. Can be `ltr` or `rtl`
data-name string The `name` attribute of the combobox's input. Useful for form submission
data-form string The associate form of the combobox.
data-disabled boolean Whether the combobox is disabled
data-read-only boolean Whether the combobox is readonly. This puts the combobox in a "non-editable" mode but the user can still interact with it
data-invalid boolean Whether the combobox is invalid
data-required boolean Whether the combobox is required
data-placeholder boolean The placeholder text of the combobox's input
data-default-highlighted-value string The initial highlighted value of the combobox when rendered. Use when you don't need to control the highlighted value of the combobox.
data-highlighted-value string The controlled highlighted value of the combobox
data-value string list The controlled value of the combobox's selected items
data--default-value string list The initial value of the combobox's selected items when rendered. Use when you don't need to control the value of the combobox's selected items.
data-input-behavior "autohighlight" | "autocomplete" | "none" Defines the auto-completion behavior of the combobox. - `autohighlight`: The first focused item is highlighted as the user types - `autocomplete`: Navigating the listbox with the arrow keys selects the item and the input is updated
data-selectionBehavior "clear" | "replace" | "preserve" The behavior of the combobox input when an item is selected - `replace`: The selected item string is set as the input value - `clear`: The input value is cleared - `preserve`: The input value is preserved
data-auto-focus boolean Whether to autofocus the input on mount
data-open-on-click boolean Whether to open the combobox popup on initial click on the input
data-open-on-change boolean Whether to open the combobox popup on initial click on the input
data-open-on-click boolean Whether to show the combobox when the input value changes
data-allow-custom-value boolean Whether to allow typing custom values in the input
data-loop-focus boolean Whether to loop the keyboard navigation through the items
data-multiple boolean Whether to allow multiple selection. **Good to know:** When `multiple` is `true`, the `selectionBehavior` is automatically set to `clear`. It is recommended to render the selected items in a separate container.
data-close-on-select boolean Whether to close the combobox when an item is selected.
data-composite boolean Whether the combobox is a composed with other composite widgets like tabs
data-disable-layer boolean Whether to disable registering this a dismissable layer

Callbacks

Each combobox component can receive callbacks that can be used to respond to user interaction with custom behavior.

You must add a custom id and an event listener for your event name


                  document.getElementById("my-callback-combobox")
                  ?.addEventListener("my-callback-combobox-event", (event) => {
                    console.log("Received event:", (event as CustomEvent).detail);
                  });
              
  • US Dollar
  • Euro
  • British Pound
  • Japanese Yen
  • Indian Rupee
<div id="my-callback-combobox" class="combobox-js combobox" data-placeholder="Type or select currency" data-on-input-value-change="my-callback-combobox-event">
                  <div data-part="root">
                  <label data-part="label">Your Currency</label>
                  <div data-part="control">
                  <input data-part="input">
                  <button data-part="clear-trigger">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M12 9.75 14.25 12m0 0 2.25 2.25M14.25 12l2.25-2.25M14.25 12 12 14.25m-2.58 4.92-6.374-6.375a1.125 1.125 0 0 1 0-1.59L9.42 4.83c.21-.211.497-.33.795-.33H19.5a2.25 2.25 0 0 1 2.25 2.25v10.5a2.25 2.25 0 0 1-2.25 2.25h-9.284c-.298 0-.585-.119-.795-.33Z"></path>
                  </svg>
                  </button>
                  <button data-part="trigger">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5"></path>
                  </svg>
                  </button>
                  </div>
                  <div data-part="positioner">
                  <ul data-part="content" class="scrollbar">
                  <li data-part="item" data-code="USD" data-label="US Dollar">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M12 6v12m-3-2.818.879.659c1.171.879 3.07.879 4.242 0 1.172-.879 1.172-2.303 0-3.182C13.536 12.219 12.768 12 12 12c-.725 0-1.45-.22-2.003-.659-1.106-.879-1.106-2.303 0-3.182s2.9-.879 4.006 0l.415.33M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  US Dollar
                  </li>
                  <li data-part="item" data-code="EURO" data-label="Euro">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M14.25 7.756a4.5 4.5 0 1 0 0 8.488M7.5 10.5h5.25m-5.25 3h5.25M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  Euro
                  </li>
                  <li data-part="item" data-code="GBP" data-label="British Pound">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M14.121 7.629A3 3 0 0 0 9.017 9.43c-.023.212-.002.425.028.636l.506 3.541a4.5 4.5 0 0 1-.43 2.65L9 16.5l1.539-.513a2.25 2.25 0 0 1 1.422 0l.655.218a2.25 2.25 0 0 0 1.718-.122L15 15.75M8.25 12H12m9 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  British Pound
                  </li>
                  <li data-part="item" data-code="YEN" data-label="Japanese Yen">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="m9 7.5 3 4.5m0 0 3-4.5M12 12v5.25M15 12H9m6 3H9m12-3a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  Japanese Yen
                  </li>
                  <li data-part="item" data-code="AL" data-label="Indian Rupee">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M15 8.25H9m6 3H9m3 6-3-3h1.5a3 3 0 1 0 0-6M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  Indian Rupee
                  </li>
                  </ul>
                  </div>
                  </div>
                  </div>

Open your browser's console to see the events received when you open or close the above combobox

Data attribute Type / Options Description
data-on-input-value-change string Event name to send when the input's value changes
data-on-value-change string Event name to send when a new item is selected
data-on-highlight-change string Event name to send when an item is highlighted using the pointer or keyboard navigation.
data-on-select string Event name to send when an item is selected
data-on-open-change string Event name to send when the popup is opened
data-on-on-pointerdown-outside string Event name to send when the pointer is pressed down outside the component
data-on-focus-outside string Event name to send when the focus is moved outside the component
data-on-interact-outside string Event name to send when an interaction happens outside the component

Use with Form

Combobox can be used inside a form

You must set the id of the form and the name of the Combobox

data-form="form-id" data-name="combobox-name"
  • US Dollar
  • Euro
  • British Pound
  • Japanese Yen
  • Indian Rupee
<form id="my-form">
                  <div class="combobox-js combobox" data-form="my-form" data-name="currency" data-placeholder="Type or select currency">
                  <div data-part="root">
                  <label data-part="label">Your Currency</label>
                  <div data-part="control">
                  <input data-part="input">
                  <button data-part="clear-trigger">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M12 9.75 14.25 12m0 0 2.25 2.25M14.25 12l2.25-2.25M14.25 12 12 14.25m-2.58 4.92-6.374-6.375a1.125 1.125 0 0 1 0-1.59L9.42 4.83c.21-.211.497-.33.795-.33H19.5a2.25 2.25 0 0 1 2.25 2.25v10.5a2.25 2.25 0 0 1-2.25 2.25h-9.284c-.298 0-.585-.119-.795-.33Z"></path>
                  </svg>
                  </button>
                  <button data-part="trigger">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5"></path>
                  </svg>
                  </button>
                  </div>
                  <div data-part="positioner">
                  <ul data-part="content" class="scrollbar">
                  <li data-part="item" data-code="USD" data-label="US Dollar">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M12 6v12m-3-2.818.879.659c1.171.879 3.07.879 4.242 0 1.172-.879 1.172-2.303 0-3.182C13.536 12.219 12.768 12 12 12c-.725 0-1.45-.22-2.003-.659-1.106-.879-1.106-2.303 0-3.182s2.9-.879 4.006 0l.415.33M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  US Dollar
                  </li>
                  <li data-part="item" data-code="EURO" data-label="Euro">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M14.25 7.756a4.5 4.5 0 1 0 0 8.488M7.5 10.5h5.25m-5.25 3h5.25M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  Euro
                  </li>
                  <li data-part="item" data-code="GBP" data-label="British Pound">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M14.121 7.629A3 3 0 0 0 9.017 9.43c-.023.212-.002.425.028.636l.506 3.541a4.5 4.5 0 0 1-.43 2.65L9 16.5l1.539-.513a2.25 2.25 0 0 1 1.422 0l.655.218a2.25 2.25 0 0 0 1.718-.122L15 15.75M8.25 12H12m9 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  British Pound
                  </li>
                  <li data-part="item" data-code="YEN" data-label="Japanese Yen">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="m9 7.5 3 4.5m0 0 3-4.5M12 12v5.25M15 12H9m6 3H9m12-3a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  Japanese Yen
                  </li>
                  <li data-part="item" data-code="AL" data-label="Indian Rupee">
                  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" d="M15 8.25H9m6 3H9m3 6-3-3h1.5a3 3 0 1 0 0-6M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
                  </svg>
                  Indian Rupee
                  </li>
                  </ul>
                  </div>
                  </div>
                  </div>
                  <button class="button button--accent" type="submit">Submit</button>
                  </form>
                  <div id="result"></div>

You can use the results from the form as you wish

const formCurrency = document.getElementById('my-form') as HTMLFormElement | null;
                  const resultCurrency  = document.getElementById('result') as HTMLDivElement | null;
                  if (formCurrency && resultCurrency) {
                    formCurrency.addEventListener('submit', (e: Event) => {
                      e.preventDefault();
                      const formData = new FormData(formCurrency);
                      const currency = (formData.get('currency') as string) || 'none';
                      resultCurrency.textContent = `Submitted currency: ${currency}`;
                    });
                  }
              

Templates

Combobox components is available in the followng templates

Collapsible Date Picker