PPolaris ComponentsConnect an agent

Layout

Arranges the sections of a page: a full-width section, a two-column split with a one-third sidebar, and annotated settings sections with a title and description beside the fields.

Preview

Code

Example.jsx
import { useState } from 'react';
import { Layout, Card, BlockStack, InlineStack, Text, Badge, Banner, TextField, Select, FormLayout, Divider } from '@shopify/polaris';

const TIMEZONE_OPTIONS = [
  { label: '(GMT-05:00) Eastern Time', value: 'est' },
  { label: '(GMT+00:00) London', value: 'gmt' },
  { label: '(GMT+07:00) Bangkok', value: 'ict' },
];

const ORDER_ROWS = [
  { id: '#1042', customer: 'Mae Jemison', total: '$248.00', status: 'Paid', tone: 'success' },
  { id: '#1041', customer: 'Ellen Ochoa', total: '$96.00', status: 'Pending', tone: 'attention' },
  { id: '#1040', customer: 'Helen Sharman', total: '$412.50', status: 'Refunded', tone: 'warning' },
];

export const Example = () => {
  const [storeName, setStoreName] = useState('Northern Trail Outfitters');
  const [timezone, setTimezone] = useState('est');

  return (
    <Layout>
      <Layout.Section>
        <Banner title="Your trial ends in 6 days" tone="info">
          <p>Pick a plan to keep publishing discounts after the trial period.</p>
        </Banner>
      </Layout.Section>

      <Layout.Section>
        <Card>
          <BlockStack gap="300">
            <Text as="h2" variant="headingMd">
              Recent orders
            </Text>
            <Divider />
            <BlockStack gap="200">
              {ORDER_ROWS.map((row) => (
                <InlineStack key={row.id} align="space-between" blockAlign="center" gap="400">
                  <BlockStack gap="050">
                    <Text as="span" fontWeight="medium">
                      {row.id}
                    </Text>
                    <Text as="span" variant="bodySm" tone="subdued">
                      {row.customer}
                    </Text>
                  </BlockStack>
                  <InlineStack gap="300" blockAlign="center">
                    <Text as="span">{row.total}</Text>
                    <Badge tone={row.tone}>{row.status}</Badge>
                  </InlineStack>
                </InlineStack>
              ))}
            </BlockStack>
          </BlockStack>
        </Card>
      </Layout.Section>

      <Layout.Section variant="oneThird">
        <Card>
          <BlockStack gap="200">
            <Text as="h2" variant="headingMd">
              Payout
            </Text>
            <Text as="p" variant="headingXl" fontWeight="semibold">
              $2,480.00
            </Text>
            <Text as="p" tone="subdued">
              Scheduled for Jun 12, 2025
            </Text>
          </BlockStack>
        </Card>
      </Layout.Section>

      <Layout.AnnotatedSection
        id="store-details"
        title="Store details"
        description="Shopify and your customers will use this information to contact you."
      >
        <Card>
          <FormLayout>
            <TextField label="Store name" value={storeName} onChange={setStoreName} autoComplete="organization" />
            <Select label="Time zone" options={TIMEZONE_OPTIONS} value={timezone} onChange={setTimezone} />
          </FormLayout>
        </Card>
      </Layout.AnnotatedSection>
    </Layout>
  );
};