The list is a scrollable component in which the list rows are rendered.
import React, {useState} from 'react';
import {
Navigator,
Screen,
ScrollView,
List,
Text,
Section,
ListRowSubtitle,
reactExtension,
} from '@shopify/ui-extensions-react/point-of-sale';
const SmartGridModal = () => {
const [seeDetails, setSeeDetails] = useState(false);
const listData = [
{
id: 'graphicTees',
leftSide: {
label: 'Graphic Tees',
subtitle: [{content: 'Summer Collection'}, {content: 'Unisex'}] as [
ListRowSubtitle,
ListRowSubtitle?,
],
},
rightSide: {
label: 'Product details',
showChevron: true,
},
onPress: () => setSeeDetails(!seeDetails),
},
{
id: 'denimShorts',
leftSide: {
label: 'Denim Shorts',
subtitle: [{content: 'Summer Collection'}, {content: 'Denim'}] as [
ListRowSubtitle,
ListRowSubtitle?,
],
},
},
];
return (
<Navigator>
<Screen name="TextArea" title="Text Area Example">
<ScrollView>
<List title="Products" data={listData} />
{seeDetails && (
<Section title="Our T-shirts">
<Text>Our shirts are made with 100% organic cotton!</Text>
</Section>
)}
</ScrollView>
</Screen>
</Navigator>
);
};
export default reactExtension('pos.home.modal.render', () => (
<SmartGridModal />
));
import {
Navigator,
Screen,
ScrollView,
List,
Text,
Section,
ListRowSubtitle,
extension,
} from '@shopify/ui-extensions/point-of-sale';
export default extension('pos.home.modal.render', (root, api) => {
let showDetails = false;
const scrollView = root.createComponent(ScrollView);
const section = root.createComponent(Section, {
title: 'Our T-shirts',
});
const triggerShowDetails = () => {
showDetails = !showDetails;
if (showDetails) {
scrollView.append(section);
} else {
scrollView.removeChild(section);
}
};
const listData = [
{
id: 'graphicTees',
leftSide: {
label: 'Graphic Tees',
subtitle: [{content: 'Summer Collection'}, {content: 'Unisex'}] as [
ListRowSubtitle,
ListRowSubtitle?,
],
},
rightSide: {
label: 'Product details',
showChevron: true,
},
onPress: () => triggerShowDetails(),
},
{
id: 'denimShorts',
leftSide: {
label: 'Denim Shorts',
subtitle: [{content: 'Summer Collection'}, {content: 'Denim'}] as [
ListRowSubtitle,
ListRowSubtitle?,
],
},
},
];
const list = root.createComponent(List, {
title: 'Products',
data: listData,
});
const textBlock = root.createComponent(
Text,
null,
'Our shirts are made with 100% organic cotton!',
);
section.append(textBlock);
scrollView.append(list);
if (showDetails) {
scrollView.append(section);
}
const screen = root.createComponent(Screen, {
name: 'TextArea',
title: 'Text Area Example',
});
screen.append(scrollView);
const navigator = root.createComponent(Navigator);
navigator.append(screen);
root.append(navigator);
});
The array of `ListRow` which will be converted into rows for this list.
The logic behind displaying an image or placeholder. `automatic` will display an image or placeholder if it detects that a `ListItem` in `data` has an `imageUri` value. `never` will never display images or placeholders. `always` will always display images or placeholders if `imageUri` is undefined or empty.
Whether or not more data is being loaded. Set this to `true` when paginating and fetching more data for the list.
A header component for the list.
Callback for when the user reaches the end of the `List`. This can be used to fire a request to load more data.
A large display title at the top of the `List`.
The unique identifier for this list item.
The user interface of the left side of the row.
Callback for when the user taps the row.
The user interface of the right side of the row.
Colored badges that are displayed underneath the `title` and `subtitles`.
The main label that will be displayed on the left side of the row.
The subtitles to display beneath the main label. Up to 3 subtitles can be displayed. Subtitles can optionally be configured with colors by passing an object with a `content` and `color` properties.
A circle icon displaying the status of the badge.
The text displayed inside the badge.
The appearance and function of the badge.
'empty' | 'partial' | 'complete'
'neutral' | 'critical' | 'warning' | 'success' | 'highlight'
string | SubtitleType
Property used to modify the subtitle appearance.
The subtitles to display beneath the main label.
'TextNeutral' | 'TextSubdued' | 'TextDisabled' | 'TextWarning' | 'TextCritical' | 'TextSuccess' | 'TextInteractive' | 'TextHighlight'
The main label that will be displayed on the right side of the row.
Show a chevron. Set this to true if pressing on the row navigates to another screen.
A toggle switch that is be displayed on the right side of the row.
Whether or not the toggle switch is disabled.
Whether or not the toggle switch is on or off.