Video thumbnail
A clickable poster image with a play button and duration badge that launches a video, optionally showing how far the viewer has watched.
Preview
Code
Example.jsx
import { useState } from 'react';
import { Card, Box, BlockStack, InlineGrid, Text, VideoThumbnail, Banner, MediaCard } from '@shopify/polaris';
const OFFICE_URL = 'https://burst.shopifycdn.com/photos/business-woman-smiling-in-office.jpg?width=1850';
const DESIGNER_URL = 'https://burst.shopifycdn.com/photos/freelance-designer-working-on-laptop.jpg?width=1850';
const GRID_COLUMNS = { xs: 1, md: 2 };
const formatDuration = (seconds) => {
const minutes = Math.floor(seconds / 60);
const remainder = seconds % 60;
return `${minutes}:${String(remainder).padStart(2, '0')}`;
};
export const Example = () => {
const [playing, setPlaying] = useState(null);
return (
<BlockStack gap="400">
{playing && (
<Banner tone="info" title="Video started" onDismiss={() => setPlaying(null)}>
<Text as="p">
Playing {playing.title} ({formatDuration(playing.videoLength)}). In a real app this opens the player in a
modal.
</Text>
</Banner>
)}
<InlineGrid columns={GRID_COLUMNS} gap="400">
<Card padding="0">
<VideoThumbnail
videoLength={175}
thumbnailUrl={OFFICE_URL}
accessibilityLabel="Play Set up your first discount, 2 minutes 55 seconds"
onClick={() => setPlaying({ title: 'Set up your first discount', videoLength: 175 })}
/>
<Box padding="300">
<BlockStack gap="050">
<Text as="h3" variant="headingSm">
Set up your first discount
</Text>
<Text as="p" variant="bodySm" tone="subdued">
Not started
</Text>
</BlockStack>
</Box>
</Card>
<Card padding="0">
<VideoThumbnail
videoLength={320}
videoProgress={148}
showVideoProgress
thumbnailUrl={DESIGNER_URL}
accessibilityLabel="Play Customize your theme, 5 minutes 20 seconds"
onClick={() => setPlaying({ title: 'Customize your theme', videoLength: 320 })}
/>
<Box padding="300">
<BlockStack gap="050">
<Text as="h3" variant="headingSm">
Customize your theme
</Text>
<Text as="p" variant="bodySm" tone="subdued">
Watched 2:28 of 5:20
</Text>
</BlockStack>
</Box>
</Card>
</InlineGrid>
<MediaCard
title="Getting started with Shopify Payments"
primaryAction={{
content: 'Watch the walkthrough',
onAction: () => setPlaying({ title: 'Getting started with Shopify Payments', videoLength: 246 }),
}}
description="Learn how to accept credit cards, set your payout schedule, and handle chargebacks."
popoverActions={[{ content: 'Dismiss', onAction: () => setPlaying(null) }]}
>
<VideoThumbnail
videoLength={246}
thumbnailUrl={OFFICE_URL}
accessibilityLabel="Play Getting started with Shopify Payments, 4 minutes 6 seconds"
onClick={() => setPlaying({ title: 'Getting started with Shopify Payments', videoLength: 246 })}
/>
</MediaCard>
</BlockStack>
);
};