PPolaris ComponentsConnect an agent

Page

The outermost shell of a Shopify admin screen: it renders the title, subtitle, back action, primary action and the secondary action menu above your content.

Preview

Code

Example.jsx
import { useState } from 'react';
import { Page, Card, BlockStack, InlineStack, Text, Badge, Divider } from '@shopify/polaris';
import { DuplicateIcon, ViewIcon, DeleteIcon } from '@shopify/polaris-icons';

const SUMMARY_ROWS = [
  { label: 'Type', value: 'Automatic discount' },
  { label: 'Method', value: '20% off all outerwear' },
  { label: 'Combinations', value: 'Combines with shipping discounts' },
  { label: 'Active dates', value: 'Jun 1 – Aug 31, 2025' },
];

export const Example = () => {
  const [active, setActive] = useState(false);

  return (
    <Page
      backAction={{ content: 'Discounts', onAction: () => {} }}
      title="Summer sale"
      subtitle="Automatic discount for the outerwear collection"
      titleMetadata={<Badge tone={active ? 'success' : 'info'}>{active ? 'Active' : 'Draft'}</Badge>}
      compactTitle
      primaryAction={{
        content: active ? 'Deactivate' : 'Activate',
        tone: active ? 'critical' : undefined,
        onAction: () => setActive((prev) => !prev),
      }}
      secondaryActions={[
        { content: 'Duplicate', icon: DuplicateIcon, onAction: () => {} },
        { content: 'Preview', icon: ViewIcon, onAction: () => {} },
        { content: 'Delete', icon: DeleteIcon, destructive: true, onAction: () => {} },
      ]}
      pagination={{ hasPrevious: true, hasNext: true }}
    >
      <Card>
        <BlockStack gap="300">
          <Text as="h2" variant="headingMd">
            Discount summary
          </Text>
          <Divider />
          <BlockStack gap="200">
            {SUMMARY_ROWS.map((row) => (
              <InlineStack key={row.label} align="space-between" gap="400">
                <Text as="span" tone="subdued">
                  {row.label}
                </Text>
                <Text as="span" fontWeight="medium">
                  {row.value}
                </Text>
              </InlineStack>
            ))}
          </BlockStack>
        </BlockStack>
      </Card>
    </Page>
  );
};