Close
Angular React Web Components Blazor
Open Source

React ComboBox Templates

The Ignite UI for React 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.

type City = {
  name: string;
  id: string;
  country: string;
};

const renderItemTemplate = (args: ComboTemplateProps<City>) => {
  const item = args.item;

  return (
    <span>
      <b>{item.name}</b> [{item.id}] - {item.country}
    </span>
  );
};

<IgrCombo
    valueKey="id"
    displayKey="name"
    groupKey="country"
    data={Cities}
    itemTemplate={renderItemTemplate}
></IgrCombo>

Group Header Template

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

<IgrCombo
    valueKey="id"
    displayKey="name"
    groupKey="country"
    data={cities}
    groupHeaderTemplate={renderGroupHeaderTemplate}
></IgrCombo>

const renderGroupHeaderTemplate = (args: ComboTemplateProps<City>) => {
  return (
  <span>Country of {args.item.country}</span>
  );
}

Slots

Other than custom templates, the Ignite UI for React 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:

<IgrCombo>
  <header slot="header">
        Header content goes here
  </header>
</IgrCombo>

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

<IgrCombo>
  <footer slot="footer">
        Footer content goes here
  </footer>
</IgrCombo>

Empty List Slot

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

<IgrCombo>
  <div slot="empty">¯\_(ツ)_/¯</div>
</IgrCombo>

Toggle Icon Slot

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

<IgrCombo>
  <span slot="toggle-icon">
    <IgrIcon name="down" collection="material"></IgrIcon>
  </span>
</IgrCombo>

Clear Icon Slot

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

<IgrCombo>
  <span slot="clear-icon">
    <IgrIcon name="clear" collection="material"></IgrIcon>
  </span>
</IgrCombo>

API References

Additional Resources