Links

Arguments

Raycast supports arguments for your commands so that users can enter values right from Root Search before opening the command.
Arguments are configured in the manifest per command.
  • Maximum number of arguments: 3 (if you have a use case that requires more, please let us know via feedback or in the Slack community)
  • The order of the arguments specified in the manifest is important and is reflected by the fields shown in Root Search. To provide a better UX, put the required arguments before the optional ones.

Example

Let's say we want a command with two arguments. Its package.json will look like this:
{
"name": "arguments",
"title": "API Arguments",
"description": "Example of Arguments usage in the API",
"icon": "command-icon.png",
"author": "mattisssa",
"license": "MIT",
"commands": [
{
"name": "arguments",
"title": "Arguments",
"subtitle": "API Examples",
"description": "Demonstrates usage of arguments",
"mode": "view",
"arguments": [
{
"name": "title",
"placeholder": "Title",
"type": "text",
"required": true
},
{
"name": "subtitle",
"placeholder": "Subtitle",
"type": "text"
}
]
}
],
"dependencies": {
"@raycast/api": "1.38.0"
},
"scripts": {
"dev": "ray develop",
"build": "ray build -e dist",
"lint": "ray lint"
}
}
The command itself will receive the arguments' values via the arguments prop:
import { Form, LaunchProps } from "@raycast/api";
interface TodoArguments {
title: string;
subtitle?: string;
}
export default function Todoist(props: LaunchProps<{ arguments: TodoArguments }>) {
const { title, subtitle } = props.arguments;
console.log(`title: ${title}, subtitle: ${subtitle}`);
return (
<Form>
<Form.TextField id="title" title="Title" defaultValue={title} />
<Form.TextField id="subtitle" title="Subtitle" defaultValue={subtitle} />
</Form>
);
}

Types

Arguments

A command receives the values of its arguments via a top-level prop named arguments. It is an object with the arguments' name as keys and their values as the property's values.
Depending on the type of the argument, the type of its value will be different.
Argument type
Value type
text
string
password
string