The "text" variant of an <uwc-input> can be constructed by setting the [type] attribute to "text".

It is also the default type.

You can do quite a lot with this type and below you'll find common patterns to use this element with.

It is possible to add a popup that is anchored to the input element by specifying a dialog[popover] child.

This can - for example - be used to implement comboboxes. A combobox generally allows you to type a value (and act on that) while associating it with content in a popup next to it.

For more details see WAI Combobox pattern

Note that everything in the popup that counts as a value element can be selected.

If you don't want your users to be able to type some arbitrary values but to select from a "curated" list you can hide the root element.

Note that you can still type some text and the highlighted suggestion will be selected according to a (exact) text match.

You can add content like icons and other stuff before or after the root element by specifying the initial "mountpoint" for the root element with a [part=root] element.

E.g. to add a "clear" button at the end:

You can also control where selected values are added by specifying a ul[part=values] element.

This can also be used to specify initial values if desired.

By providing a template inside the ul[part=values] element it is possible to specify how selected values are rendered.

In short, there are three things to consider:

  1. data-value - or the text content of a li element if not specified - is what's going to be what's added to the form data.
  2. data-label - or the text content of a li element if not specified - is what's going to be placed in unnamed slots.
  3. data-slot-attributes can be used to copy attributes from the selected element inside the popup to the new element in ul[part=values]