PPolaris ComponentsConnect an agent

Scrollable

A fixed-height container that scrolls its overflowing content, with edge shadows that hint there is more to read and optional keyboard focus.

Preview

Code

Example.jsx
import { Card, Box, BlockStack, InlineStack, Text, Badge, Divider, Scrollable } from '@shopify/polaris';

const SCROLLABLE_STYLE = { height: '200px' };

const TERMS = [
  {
    heading: '1. Subscription',
    body: 'Your plan renews automatically every 30 days until you cancel it. Charges appear on your Shopify invoice on the same day your billing cycle starts.',
  },
  {
    heading: '2. Trial period',
    body: 'New stores get a 14-day free trial. If you uninstall before the trial ends you are never charged, and your settings are kept for 30 days in case you come back.',
  },
  {
    heading: '3. Usage limits',
    body: 'The Starter plan includes 5,000 monthly impressions. Once you pass the limit the widget keeps working, and the overage is billed at the end of the cycle.',
  },
  {
    heading: '4. Data retention',
    body: 'Analytics are kept for 12 months on paid plans and 30 days on the free plan. You can export everything to CSV at any time from the reports page.',
  },
  {
    heading: '5. Cancellation',
    body: 'Uninstalling the app cancels the subscription immediately. Any unbilled usage from the current cycle is charged on your next Shopify invoice.',
  },
];

const APPS = [
  { name: 'Product reviews', status: 'Installed', tone: 'success' },
  { name: 'Email marketing', status: 'Installed', tone: 'success' },
  { name: 'Loyalty points', status: 'Trial', tone: 'attention' },
  { name: 'Bundle builder', status: 'Installed', tone: 'success' },
  { name: 'Back in stock', status: 'Paused', tone: 'warning' },
  { name: 'Wholesale pricing', status: 'Trial', tone: 'attention' },
  { name: 'Shipping calculator', status: 'Installed', tone: 'success' },
];

export const Example = () => (
  <BlockStack gap="400">
    <Card>
      <BlockStack gap="300">
        <Text as="h2" variant="headingMd">
          Terms of service
        </Text>
        <Scrollable shadow focusable style={SCROLLABLE_STYLE}>
          <Box padding="200">
            <BlockStack gap="300">
              {TERMS.map((term) => (
                <BlockStack key={term.heading} gap="100">
                  <Text as="h3" variant="headingSm">
                    {term.heading}
                  </Text>
                  <Text as="p" tone="subdued">
                    {term.body}
                  </Text>
                </BlockStack>
              ))}
            </BlockStack>
          </Box>
        </Scrollable>
      </BlockStack>
    </Card>

    <Card padding="0">
      <Box padding="400" paddingBlockEnd="300">
        <Text as="h2" variant="headingMd">
          Installed apps
        </Text>
      </Box>
      <Scrollable shadow focusable hint style={SCROLLABLE_STYLE}>
        <BlockStack>
          {APPS.map((app, index) => (
            <BlockStack key={app.name}>
              {index > 0 && <Divider />}
              <Box paddingInline="400" paddingBlock="300">
                <InlineStack align="space-between" blockAlign="center">
                  <Text as="span">{app.name}</Text>
                  <Badge tone={app.tone}>{app.status}</Badge>
                </InlineStack>
              </Box>
            </BlockStack>
          ))}
        </BlockStack>
      </Scrollable>
    </Card>
  </BlockStack>
);