Skip to main content

Picker API

Requires an Admin block, action, or print extension.

The Picker API provides a search-based interface to help users find and select one or more resources that you provide, such as product reviews, email templates, or subscription options, and then returns the selected resource ids to your extension.

Tip

If you are picking products, product variants, or collections, you should use the Resource Picker API instead.

The picker API is a function that accepts an options argument for configuration and returns a Promise that resolves to the picker instance once the picker modal is opened.

required

Promise<>
Examples

js

const {picker} = useApi(TARGET);

const pickerInstance = await picker({
heading: 'Select a template',
multiple: false,
headers: [
{title: 'Templates'},
{title: 'Created by'},
{title: 'Times used', type: 'number'},
],
items: [
{
id: '1',
heading: 'Full width, 1 column',
data: ['Karine Ruby', '0'],
badges: [{content: 'Draft', tone: 'info'}, {content: 'Marketing'}],
},
{
id: '2',
heading: 'Large graphic, 3 column',
data: ['Russell Winfield', '5'],
badges: [
{content: 'Published', tone: 'success'},
{content: 'New feature'},
],
selected: true,
},
{
id: '3',
heading: 'Promo header, 2 column',
data: ['Russel Winfield', '10'],
badges: [{content: 'Published', tone: 'success'}],
},
],
});

const selected = await pickerInstance.selected;

Preview

Was this page helpful?