List View
The List View response tells the Command Bar to display a list of options.
  • type: "list"
  • options: An array of ListOption objects.
  • groups: Optional. An array of Group objects (or strings). Can be used to define the order in which they appear and customize how they are displayed.
  • ranking: Optional. The default value is true, i.e the Command Bar's default ranking will be used. If you wish to return different options as the user types in the Command Bar, set ranking to false. Then Slapdash will run your command with a special parameter keywords that you can use to decide what options to return back.
Options to open, copy, paste a URL or show it in a toast
Grouped options
1
{
2
"view": {
3
"type": "list",
4
"options": [
5
{
6
"title": "Open Google",
7
"action": {
8
"type": "open-url",
9
"url": "https://www.google.com/"
10
}
11
},
12
{
13
"title": "Copy Google URL",
14
"action": {
15
"type": "copy",
16
"value": "https://www.google.com/"
17
}
18
},
19
{
20
"title": "Paste Google URL",
21
"action": {
22
"type": "paste",
23
"value": "https://www.google.com/"
24
}
25
},
26
{
27
"title": "Show Google URL",
28
"action": {
29
"type": "show-toast",
30
"message": "https://www.google.com/"
31
}
32
}
33
]
34
}
35
}
Copied!
1
{
2
"view": {
3
"type": "list",
4
"groups": ["Clipboard", "Browser", "Misc"],
5
"options": [
6
{
7
"title": "Open Google",
8
"group": "Browser",
9
"action": {
10
"type": "open-url",
11
"url": "https://www.google.com/"
12
}
13
},
14
{
15
"title": "Copy Google URL",
16
"group": "Clipboard",
17
"action": {
18
"type": "copy",
19
"value": "https://www.google.com/"
20
}
21
},
22
{
23
"title": "Paste Google URL",
24
"group": "Clipboard",
25
"action": {
26
"type": "paste",
27
"value": "https://www.google.com/"
28
}
29
},
30
{
31
"title": "Show Google URL",
32
"group": "Misc",
33
"action": {
34
"type": "show-toast",
35
"message": "https://www.google.com/"
36
}
37
}
38
]
39
}
40
}
Copied!

ListOption

Property CommandResponse.view.options is the list of options that are displayed in the List View.
  • title: The title for the option.
  • action: Option's Main Action. This Action is executed when Enter is pressed on the Option (or when the option is clicked).
  • moveAction: Optional. Option's Move Action object. This Action is executed when Tab is pressed on the Option.
  • icon: Optional. The Icon for the option.
  • subtitle: Optional. The subtitle for the option. Can be provided as a string or a list of strings.
  • group: Optional. The Group this option belongs to.
List View: options with a custom icon and subtitle
1
{
2
"view": {
3
"type": "list",
4
"options": [
5
{
6
"title": "Copy Home Number",
7
"subtitle": [
8
"Mobile",
9
"Emergencies"
10
],
11
"group": "Phone Numbers",
12
"icon": "🏠",
13
"action": {
14
"type": "copy",
15
"value": "+44123456789"
16
}
17
},
18
{
19
"title": "Copy Work Number",
20
"subtitle": [
21
"Stationary",
22
"9-5"
23
],
24
"group": "Phone Numbers",
25
"icon": "💼",
26
"action": {
27
"type": "copy",
28
"value": "+44987654321"
29
}
30
}
31
]
32
}
33
}
Copied!

Group

Property CommandResponse.view.groups allows to display options in the List View in groups. Each Group can be a string or an object. Provide Group as an object if you want to customize its appearance (e.g. change its title).
List View: custom order for groups
List View: custom title for a group
1
{
2
"view": {
3
"type": "list",
4
"groups": [
5
"misc",
6
"browser",
7
"clipboard"
8
],
9
"options": [
10
{
11
"title": "Open Google",
12
"group": "browser",
13
"action": {
14
"type": "open-url",
15
"url": "https://www.google.com/"
16
}
17
},
18
{
19
"title": "Copy Google URL",
20
"group": "clipboard",
21
"action": {
22
"type": "copy",
23
"value": "https://www.google.com/"
24
}
25
},
26
{
27
"title": "Paste Google URL",
28
"group": "clipboard",
29
"action": {
30
"type": "paste",
31
"value": "https://www.google.com/"
32
}
33
},
34
{
35
"title": "Show Google URL",
36
"group": "misc",
37
"action": {
38
"type": "show-toast",
39
"message": "https://www.google.com/"
40
}
41
}
42
]
43
}
44
}
Copied!
1
{
2
"view": {
3
"type": "list",
4
"groups": [
5
{
6
"id": "misc",
7
"title": "Miscellaneous"
8
},
9
"browser",
10
"clipboard"
11
],
12
"options": [
13
{
14
"title": "Open Google",
15
"group": "browser",
16
"action": {
17
"type": "open-url",
18
"url": "https://www.google.com/"
19
}
20
},
21
{
22
"title": "Copy Google URL",
23
"group": "clipboard",
24
"action": {
25
"type": "copy",
26
"value": "https://www.google.com/"
27
}
28
},
29
{
30
"title": "Paste Google URL",
31
"group": "clipboard",
32
"action": {
33
"type": "paste",
34
"value": "https://www.google.com/"
35
}
36
},
37
{
38
"title": "Show Google URL",
39
"group": "misc",
40
"action": {
41
"type": "show-toast",
42
"message": "https://www.google.com/"
43
}
44
}
45
]
46
}
47
}
Copied!

Option's Main Action

The Main Action for an Option can be provided as the plain Action object or as a special object that allows to customize how the action is visualised by the Command Bar.
1
type OptionMainAction =
2
| Action
3
| {
4
/** The default Action object. */
5
action: Action;
6
/** The label for this action. By default it will be inferred
7
* from the action property. */
8
label?: string;
9
/** The tooltip for this action. By default it will be inferred
10
* from the action property. */
11
tooltip?: string;
12
/** The icon for this action. Either an emoji or an Image URL.
13
* By default it will be inferred from the action property. */
14
icon?: Icon;
15
};
Copied!
List View: custom affordances for the option
List View: default affordances for the option
1
{
2
"view": {
3
"type": "list",
4
"options": [
5
{
6
"title": "Open Google",
7
"action": {
8
"label": "Open Browser",
9
"icon": "🌎",
10
"tooltip": "Open Google in the Browser",
11
"action": {
12
"type": "open-url",
13
"url": "https://www.google.com/"
14
}
15
}
16
}
17
]
18
}
19
}
Copied!
1
{
2
"view": {
3
"type": "list",
4
"options": [
5
{
6
"title": "Open Google",
7
"action": {
8
"type": "open-url",
9
"url": "https://www.google.com/"
10
}
11
}
12
]
13
}
14
}
Copied!

Option's Move Action

Property CommandResponse.view.options[].moveAction allows providing a Move Action to change the location of the Command Bar.
Masonry View: option with
1
{
2
"view": {
3
"type": "masonry",
4
"options": [
5
{
6
"imageURL": "https://images.unsplash.com/photo-1481819613568-3701cbc70156",
7
"action": {
8
"type": "open-url",
9
"url": "https://images.unsplash.com/photo-1481819613568-3701cbc70156"
10
},
11
"moveAction": {
12
"type": "add-param",
13
"name": "image",
14
"value": "moon"
15
}
16
}
17
]
18
}
19
}
Copied!
Last modified 1mo ago