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

    EXAMPLE
    TS
    HTML
    CSS

    Like this sample? Get access to our complete Ignite UI for Web Components toolkit and start building your own apps in minutes. Download it for free.

    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;
    ts

    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;
    ts
    Ignite UI for Web Components | CTA Banner

    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 combo parts.

    Header Slot

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

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

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

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

    Empty List Slot

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

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

    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>
    html

    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>
    html

    API Reference

    Additional Resources