PPolaris ComponentsConnect an agent

Bleed

Cancels out the padding of its parent with negative margins, so a banner, image or divider can run edge to edge inside a Card.

Preview

Code

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

const REGIONS = [
  { id: 'domestic', name: 'Domestic', rates: '3 rates' },
  { id: 'international', name: 'International', rates: '1 rate' },
];

export const Example = () => (
  <BlockStack gap="400">
    <Card>
      <BlockStack gap="300">
        <Text as="h2" variant="headingMd">
          Without Bleed
        </Text>
        <Box background="bg-surface-secondary" borderRadius="200" padding="300">
          <Text as="span" variant="bodySm">
            This block stops at the card padding on every side.
          </Text>
        </Box>
        <Text as="p" tone="subdued">
          The card keeps its 400 of padding, so the tinted block is inset.
        </Text>
      </BlockStack>
    </Card>

    <Card>
      <BlockStack gap="300">
        <Text as="h2" variant="headingMd">
          marginInline="400"
        </Text>
        <Bleed marginInline="400">
          <Box background="bg-surface-secondary" padding="300">
            <Text as="span" variant="bodySm">
              This block bleeds out to the left and right card edges.
            </Text>
          </Box>
        </Bleed>
        <Text as="p" tone="subdued">
          Negative inline margins cancel the card's horizontal padding.
        </Text>
      </BlockStack>
    </Card>

    <Card>
      <BlockStack gap="300">
        <Text as="h2" variant="headingMd">
          A full-bleed divider and footer
        </Text>
        <BlockStack gap="200">
          {REGIONS.map((region) => (
            <InlineStack key={region.id} align="space-between" blockAlign="center">
              <Text as="span">{region.name}</Text>
              <Badge>{region.rates}</Badge>
            </InlineStack>
          ))}
        </BlockStack>
        <Bleed marginInline="400" marginBlockEnd="400">
          <Divider />
          <Box background="bg-surface-secondary" padding="400">
            <Text as="span" variant="bodySm" tone="subdued">
              marginInline="400" marginBlockEnd="400" — the footer reaches the bottom and side edges.
            </Text>
          </Box>
        </Bleed>
      </BlockStack>
    </Card>
  </BlockStack>
);