Skip to main content
Unlisted page
This page is unlisted. Search engines will not index it, and only users having a direct link can access it.

setCustomComponent(slug, getComponent)

Sets a CommandBar component to custom HTML or to a custom component in Spotlight (.addComponent). This is only available to select enterprise customers — please reach out to team@commandbar.com if you'd like to use this feature.

Example

// set a custom footer
window.CommandBar.setCustomComponent("footer", customFooter);

// set a custom default state
window.CommandBar.setCustomComponent(
"defaultState",
() => `
<div style="padding: 3rem; text-align: center"><p>Try searching for something!</p>
<img width="100%" src="https://cdn2.lamag.com/wp-content/uploads/sites/6/2017/01/alvan-nee-1316903-unsplash.jpg" />
</div>
`
);

Method parameters

slug Required

'header' | 'input' | 'sidepanel' | 'footer' | 'navPaneHeader' | 'navPaneFooter' | 'defaultState' | 'emptyState'

The component that you want to customize.

  • header: appears above the search input
  • input: appears within the search input
  • sidepanel: appears to the right of the search input
  • footer: appears below Spotlight
  • navPaneHeader: appears above the navigation pane
  • navPaneFooter: appears below the navigation pane
  • defaultState: takes over the default bar state when there the input is blank
  • emptyState: takes over the no results view in Spotlight

getComponent Required

(() => CustomComponent | () => HTMLString)

A function that returns either an HTML string or customComponent.