Icon
Renders a Polaris icon SVG at a consistent 20x20 size, with tones that colour it for success, critical, caution, info, magic and subdued states.
Preview
Code
Example.jsx
import { Card, Box, BlockStack, InlineStack, InlineGrid, Text, Icon, Divider } from '@shopify/polaris';
import { OrderIcon, ProductIcon, PersonIcon, CartIcon, PaymentIcon, DiscountIcon, StoreIcon, ChartVerticalIcon, SettingsIcon, NotificationIcon, SearchIcon, StarIcon, DeliveryIcon, InventoryIcon, EmailIcon, GiftCardIcon, ThemeIcon, AppsIcon, CheckCircleIcon, AlertTriangleIcon, XCircleIcon, InfoIcon, MagicIcon } from '@shopify/polaris-icons';
const COMMON_ICONS = [
{ label: 'OrderIcon', source: OrderIcon },
{ label: 'ProductIcon', source: ProductIcon },
{ label: 'PersonIcon', source: PersonIcon },
{ label: 'CartIcon', source: CartIcon },
{ label: 'PaymentIcon', source: PaymentIcon },
{ label: 'DiscountIcon', source: DiscountIcon },
{ label: 'StoreIcon', source: StoreIcon },
{ label: 'ChartVerticalIcon', source: ChartVerticalIcon },
{ label: 'SettingsIcon', source: SettingsIcon },
{ label: 'NotificationIcon', source: NotificationIcon },
{ label: 'SearchIcon', source: SearchIcon },
{ label: 'StarIcon', source: StarIcon },
{ label: 'DeliveryIcon', source: DeliveryIcon },
{ label: 'InventoryIcon', source: InventoryIcon },
{ label: 'EmailIcon', source: EmailIcon },
{ label: 'GiftCardIcon', source: GiftCardIcon },
{ label: 'ThemeIcon', source: ThemeIcon },
{ label: 'AppsIcon', source: AppsIcon },
];
const TONES = [
{ tone: 'base', source: StoreIcon },
{ tone: 'subdued', source: InfoIcon },
{ tone: 'success', source: CheckCircleIcon },
{ tone: 'critical', source: XCircleIcon },
{ tone: 'caution', source: AlertTriangleIcon },
{ tone: 'warning', source: AlertTriangleIcon },
{ tone: 'info', source: InfoIcon },
{ tone: 'magic', source: MagicIcon },
{ tone: 'primary', source: OrderIcon },
{ tone: 'interactive', source: SearchIcon },
];
const STATUS_MESSAGES = [
{ tone: 'success', source: CheckCircleIcon, message: 'Order #1042 was fulfilled and tracking was sent.' },
{ tone: 'caution', source: AlertTriangleIcon, message: 'Only 3 units of Sunrise ceramic mug left in stock.' },
{ tone: 'critical', source: XCircleIcon, message: 'The payment for order #1039 was declined.' },
{ tone: 'magic', source: MagicIcon, message: 'Generate a product description with Shopify Magic.' },
];
const GRID_COLUMNS = { xs: 2, sm: 3, md: 6 };
const TONE_COLUMNS = { xs: 3, sm: 5 };
const Section = ({ title, children }) => (
<BlockStack gap="300">
<Text as="h2" variant="headingSm" tone="subdued">
{title}
</Text>
{children}
</BlockStack>
);
export const Example = () => (
<BlockStack gap="400">
<Card>
<Section title="Common icons">
<InlineGrid columns={GRID_COLUMNS} gap="300">
{COMMON_ICONS.map((item) => (
<Box key={item.label} background="bg-surface-secondary" padding="300" borderRadius="200">
<BlockStack gap="150" inlineAlign="center">
<Icon source={item.source} />
<Text as="span" variant="bodyXs" tone="subdued" alignment="center">
{item.label}
</Text>
</BlockStack>
</Box>
))}
</InlineGrid>
</Section>
</Card>
<Card>
<BlockStack gap="500">
<Section title="Tones">
<InlineGrid columns={TONE_COLUMNS} gap="300">
{TONES.map((item) => (
<BlockStack key={item.tone} gap="150" inlineAlign="center">
<Icon source={item.source} tone={item.tone} />
<Text as="span" variant="bodyXs" tone="subdued" alignment="center">
{item.tone}
</Text>
</BlockStack>
))}
</InlineGrid>
</Section>
<Divider />
<Section title="Paired with text">
<BlockStack gap="200">
{STATUS_MESSAGES.map((item) => (
<InlineStack key={item.tone} gap="150" blockAlign="center" wrap={false}>
<Icon source={item.source} tone={item.tone} />
<Text as="span">{item.message}</Text>
</InlineStack>
))}
</BlockStack>
</Section>
</BlockStack>
</Card>
</BlockStack>
);