Close
Angular React Web Components Blazor Web Components
Open Source

Web Components ComboBox Templates

The Ignite UI for Web Components ComboBox component allows defining custom templates for different areas such as items, group headers, empty list, and icons.

ComboBox Templates Example

Template Types

Item Template

The ItemTemplate is a custom template that if defined should be used when rendering items in the list of options.

import { ComboItemTemplate } from 'igniteui-webcomponents';

const itemTemplate: ComboItemTemplate<City> = ({ item }) => {
  return html`
      <span><b>${item.name}</b> [${item.id}]</span>
  `;
};

combo.itemTempate = itemTemplate;

Group Header Template

The GroupHeaderTemplate is a custom template that if defined should be used when rendering group headers in the list of options.

import { ComboItemTemplate } from 'igniteui-webcomponents';

const groupHeaderTemplate: ComboItemTemplate<City> = ({ item }) => {
  return html`<div>Country of ${item.country}</div>`;
};

combo.groupHeaderTemplate = groupHeaderTemplate;

Slots

Other than custom templates, the Ignite UI for Web Components ComboBox component exposes several slots that allow users to pass custom content to different parts of the component. For all ComboBox slots, we recommend using a <span> element for simple text, symbols, or emojis, and an <igc-icon> component when adding icons. For the header and footer slots, you can also use more semantic elements such as <header> and <footer>.

Header Slot

To render a custom header above the list of options pass content to the header slot:

<igc-combo>
  <span slot="header">Custom header content</span>
</igc-combo>

To render a custom footer below the list of options pass content to the footer slot:

<igc-combo>
  <span slot="footer">Custom footer content</span>
</igc-combo>

Empty List Slot

To render a custom content when the filtering operation returns no result, use the empty slot:

<igc-combo>
  <span slot="empty">¯\_(ツ)_/¯</span>
</igc-combo>

Toggle Icon Slot

The toggle icon in the combo input can also be modified via the toggle-icon slot:

<igc-combo>
  <igc-icon name="down" slot="toggle-icon"></igc-icon>
</igc-combo>

Clear Icon Slot

The clear icon can be changed via the clear-icon slot:

<igc-combo>
  <igc-icon name="clear" slot="clear-icon"></igc-icon>
</igc-combo>

API References

Additional Resources