List View
Display a list of items.
interface CommandJSONViewList { type: 'list'; shouldFilter?: boolean; items: CommandJSONViewListItem[];}
Property | Type | Description |
---|---|---|
type | list | The view type |
items | CommandJSONViewListItem[] | The list items |
shouldFilter | ?boolean | Whether to filter the items when the Command Bar search panel value is changed |
Example
console.log(JSON.stringify({ view: { type: 'list', items: [ { value: 'open-url', icon: 'icon:Link', title: 'Open an URL', actions: [ { type: 'open-url', url: 'https://google.com', defaultAction: true } ], }, { value: 'paste-emoji', icon: 'icon:Clipboard', title: 'Paste Emoji', actions: [ { type: 'paste', content: 'π€―', defaultAction: true } ], }, ], }}))
const emojis = ['π€―', 'π', 'β
', 'π', 'π', 'π©', 'π΄', 'π
', 'π€', 'β', 'πΏ', 'π'];
console.log(JSON.stringify({ view: { type: 'list', items: emojis.map((emoji, index) => ({ value: `emoji-${index}`, title: emoji, actions: [ { type: 'paste', content: emoji, defaultAction: true }, { type: 'open-url', url: `https://emojipedia.org/${emoji}` }, ], })), }}))
console.log(JSON.stringify({ view: { type: 'list', items: [ { group: 'Emoji', title: 'π', value: 'emoji-1', actions: [ { type: 'paste', content: 'π', defaultAction: true }, ], }, { title: 'πΏ', group: 'Emoji', value: 'emoji-2', actions: [ { type: 'paste', content: 'πΏ', defaultAction: true }, ], }, { title: 'γΎ(β§β½β¦*)o', group: 'Kaomoji', value: 'kaomoji-1', actions: [ { type: 'paste', content: 'γΎ(β§β½β¦*)o', defaultAction: true }, ], }, ], }}))
List Item
Item for the list
type view.
interface CommandJSONViewListItem { title: string; value: string; icon?: string; group?: string; subtitle?: string; description?: string; actions?: CommandJSONViewListItemAction[];}
Property | Type | Description |
---|---|---|
value | string | The list itemβs unique value |
title | string | The list itemβs title that will be displayed |
icon | ?string | The list itemβs icon. This can be an image URL or use the icon:ICON_NAME format to use the built-in icon. Replace the ICON_NAME with the iconβs name you can find here. |
actions | ?CommandJSONViewListItemAction[] | The list itemβs actions |
subtitle | ?string | Subtitle that will be displayed next to the title |
description | ?string | Shortcut description about the item |
List Item Action
Action of the list item. itβs similar with the Action except it has additional properties.
interface CommandJSONViewListItemAction extends CommandJSONAction { defaultAction?: boolean;}
Property | Type | Description |
---|---|---|
defaultAction | ?boolean | Whether to perform the current action when the user selects the item |
...rest | CommandJSONAction |