Skip to main content

open(input?, config?)

Open Spotlight. If an input is supplied, it will prefill Spotlight's search input with that value. Optionally, open Spotlight with a tab or filter preselected.

Example

// Open Spotlight
window.CommandBar.open();

// Open Spotlight with "say hi" prefilled
window.CommandBar.open("say hi");

// Open Spotlight with the Navigation category preselected
window.CommandBar.open("", { categoryFilter: "navigation" });

// Open Spotlight with the category with ID 1 preselected
window.CommandBar.open("", { categoryFilter: 1 });

// Add a record set, and open Spotlight filtering on that record set with "apple" prefilled
window.CommandBar.addRecords("fruit", [
{
label: "Apple",
value: "apple",
description: "Red fruit",
},
{
label: "Banana",
value: "banana",
description: "Yellow fruit",
},
]);

window.CommandBar.open("apple", { categoryFilter: "fruit" });

Method parameters

input

string

Optional input to prefill the Spotlight's search field.

config

object

Configure how Spotlight should open.

PropertyTypeDescription
categoryFilterstring | numberOpen Spotlight with a filter preselected. If the filter exists as a tab, the tab will be selected; if not, a tag that says the filter is applied will show. Accepts either a category name or a record set name as a string or a category ID as an integer.