Imagecomponent
component
The image component displays an image to a merchant in Shopify POS.
Anchor to imageImage
- Anchor to sizesize|Default: 'l'
The size or fill size of the image.
- string
The source of the image to be displayed.
ImageProps
- size
The size or fill size of the image.
ImageSize | FillResizeMode
- src
The source of the image to be displayed.
string
export interface ImageProps {
/**
* The source of the image to be displayed.
*/
src?: string;
/**
* The size or fill size of the image.
*
* @default 'l'
*/
size?: ImageSize | FillResizeMode;
}
ImageSize
's' | 'm' | 'l' | 'xl'
FillResizeMode
FillResizeMode will apply formatting to the image to fill the container. https://reactnative.dev/docs/image#resizemode
'cover' | 'contain' | 'stretch' | 'repeat' | 'center'
Was this section helpful?
Example image
import React from 'react';
import {
Image,
Screen,
ScrollView,
Navigator,
Box,
reactExtension,
} from '@shopify/ui-extensions-react/point-of-sale';
const SmartGridModal = () => {
return (
<Navigator>
<Screen name="Image" title="Image Example">
<ScrollView>
<Image src="example.png" size="s" />
<Box blockSize="600px" inlineSize="600px" padding="400">
<Image src="example.png" size="cover" />
</Box>
</ScrollView>
</Screen>
</Navigator>
);
};
export default reactExtension('pos.home.modal.render', () => (
<SmartGridModal />
));
examples
Example image
React
import React from 'react'; import { Image, Screen, ScrollView, Navigator, Box, reactExtension, } from '@shopify/ui-extensions-react/point-of-sale'; const SmartGridModal = () => { return ( <Navigator> <Screen name="Image" title="Image Example"> <ScrollView> <Image src="example.png" size="s" /> <Box blockSize="600px" inlineSize="600px" padding="400"> <Image src="example.png" size="cover" /> </Box> </ScrollView> </Screen> </Navigator> ); }; export default reactExtension('pos.home.modal.render', () => ( <SmartGridModal /> ));
TS
import { Navigator, Screen, ScrollView, Image, extension, Box, } from '@shopify/ui-extensions/point-of-sale'; export default extension('pos.home.modal.render', (root, api) => { const image = root.createComponent(Image, { src: 'example.png', size: 's', }); const filledImage = root.createComponent(Image, { src: 'example.png', size: 'cover', }); const scrollView = root.createComponent(ScrollView); scrollView.append(image); const box = scrollView.createComponent(Box, { blockSize: '600px', inlineSize: '600px', padding: '400', }); box.append(filledImage); scrollView.append(box); const screen = root.createComponent(Screen, { name: 'Image', title: 'Image Example', }); screen.append(scrollView); const navigator = root.createComponent(Navigator); navigator.append(screen); root.append(navigator); });
Preview
