Window & Search Bar
Clear the text in the search bar.
async function clearSearchBar(options: { forceScrollToTop: boolean }): Promise<void>;
Name | Description | Type |
---|---|---|
options | Can be used to control the behaviour after the search bar is cleared. | Object |
options.forceScrollToTop | Can be used to force scrolling to the top. Defaults to scrolling to the top after the the search bar was cleared. | boolean |
A Promise that resolves when the search bar is cleared.
Closes the main Raycast window.
async function closeMainWindow(options: { clearRootSearch: boolean; popToRootType?: PopToRootType }): Promise<void>;
import { closeMainWindow } from "@raycast/api";
import { setTimeout } from "timers/promises";
export default async function Command() {
await setTimeout(1000);
await closeMainWindow({ clearRootSearch: true });
}
You can use the
popToRootType
parameter to temporarily prevent Raycast from applying the user's "Pop to Root Search" preference in Raycast; for example, when you need to interact with an external system utility and then allow the user to return back to the view command:import { closeMainWindow, PopToRootType } from "@raycast/api";
export default async () => {
await closeMainWindow({ popToRootType: PopToRootType.Suspended });
};
Name | Description | Type |
---|---|---|
options | Can be used to control the behaviour after closing the main window. | Object |
options.clearRootSearch | Clears the text in the root search bar and scrolls to the top | boolean |
options.popToRootType | Defines the pop to root behavior (PopToRootType); the default is to to respect the user's "Pop to Root Search" preference in Raycast |
A Promise that resolves when the main window is closed.
Pops the navigation stack back to root search.
async function popToRoot(options: { clearSearchBar: boolean }): Promise<void>;
import { Detail, popToRoot } from "@raycast/api";
import { useEffect } from "react";
import { setTimeout } from "timers";
export default function Command() {
useEffect(() => {
setTimeout(() => {
popToRoot({ clearSearchBar: true });
}, 3000);
}, []);
return <Detail markdown="See you soon 👋" />;
}
Name | Description | Type |
---|---|---|
options | Can be used to control the behaviour after going back to the root search. | Object |
options.clearSearchBar | | boolean |
A Promise that resolves when Raycast popped to root.
Defines the pop to root behavior when the main window is closed.
Name | Description |
---|---|
Default | Respects the user's "Pop to Root Search" preference in Raycast |
Immediate | Immediately pops back to root |
Suspended | Prevents Raycast from popping back to root |
Last modified 1mo ago