# Artifact previews

How to display AI-generated artifacts in generative AI chat.

## Key UX concepts

### Artifacts generated by AI

Artifacts are AI-generated outputs such as documents, images, code, workflows. These artifacts are rendered as previews that typically contain a label and description, with metadata and related actions.

### Types of artifact previews

You can display generated artifacts in two ways within the chat experience, each serving different user needs and interaction models:

- **Inline previews: **   These previews emphasize quick understanding and enable contextual interactions such as *download *   or *copy *   within the chat interface.
- **Canvas previews: **   These previews display in the chat and expand to show the full artifact in an adjacent area where users can view and interact with the content.

## Criteria

|  | **Inline previews** | **Canvas previews** |
| --- | --- | --- |
| **Artifact complexity** | Simple, self-contained content. For example, a .csv generated by AI that can be downloaded. | Complex, interactive content that a user can modulate. For example, canvases generated by AI containing [forms](/components/form/index.html.md)   or [wizards](/components/wizard/index.html.md)  . |
| **Content length** | Short. For example, a code snippet for a CLI command. | Long. For example, a dense document written by AI. |
| **Primary user intent** | Quick recognition and basic actions. | Detailed review, editing, or interaction. |
| **Key actions** | Quick actions. For example, download, copy, share. | Complex actions. For example, edit, annotate, or completing a task or workflow. |
| **Interaction depth** | Minimal. Users can act on the artifact without opening it. | Complex. Users need to explore or work within the content. |
| **Conversation flow** | Maintaining flow of the conversation is critical. | Artifact becomes the primary focus. |

## Inline previews

### Code snippets

Short blocks displayed directly in the conversation using [item card](/components/item-card/index.html.md) with syntax highlighting, language indicator, and copy action. Ideal for quick reference, examples, or snippets users can immediately copy and paste.

### AI assistant

JD Show me the simplest Lambda function to log S3 uploads Here is a snippet of the simplest Lambda function to log S3 uploads. Python| `def lambda_handler(event, context):
` |
| `    bucket = event['Records'][0]['s3']['bucket']['name']
` |
| `    key = event['Records'][0]['s3']['object']['key']
` |
| `    print(f"New file uploaded: {key} in bucket {bucket}")
` |
| `    return {'statusCode': 200}` |

Use of this service is subject to the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/)
```genai-artifact-preview-code-snippets.tsx
import React, { type CSSProperties } from 'react';
import ChatBubble from '@cloudscape-design/chat-components/chat-bubble';
import Button from '@cloudscape-design/components/button';
import Box from '@cloudscape-design/components/box';
import { CodeView } from '@cloudscape-design/code-view';
import pythonHighlight from '@cloudscape-design/code-view/highlight/python';
import Container from '@cloudscape-design/components/container';
import CopyToClipboard from '@cloudscape-design/components/copy-to-clipboard';
import Header from '@cloudscape-design/components/header';
import ItemCard from '@cloudscape-design/components/item-card';
import SpaceBetween from '@cloudscape-design/components/space-between';
import Avatar from '@cloudscape-design/chat-components/avatar';
import PromptInput from '@cloudscape-design/components/prompt-input';
import ButtonGroup from '@cloudscape-design/components/button-group';
import Link from '@cloudscape-design/components/link';
import { IconProps } from '@cloudscape-design/components/icon';
import { spaceScaledXs } from '@cloudscape-design/design-tokens/index.js';

const userName = 'John Doe';
const genAiName = 'AI assistant';
const genAiAvatarAriaLabel = 'Avatar of AI assistant';

const userAvatar = <Avatar ariaLabel={`Avatar of ${userName}`} initials="JD" tooltipText={userName} />;

const genAiAvatar = (
  <Avatar ariaLabel={genAiAvatarAriaLabel} color="gen-ai" iconName="gen-ai" tooltipText={genAiName} />
);

const CustomGenAIChatFooter = ({
  actionButtonIconName,
  actionButtonAriaLabel,
  message,
  onSendMessage,
  onAction,
}: {
  actionButtonIconName: IconProps.Name;
  actionButtonAriaLabel: string;
  message?: string;
  onSendMessage?: (text: string) => void;
  onAction?: (text: string) => void;
}) => {
  return (
    <SpaceBetween size="xs">
      <PromptInput
        value={message ?? ''}
        onChange={({ detail }) => onSendMessage?.(detail.value)}
        onAction={({ detail }) => onAction?.(detail.value)}
        disableSecondaryActionsPaddings
        actionButtonAriaLabel={actionButtonAriaLabel}
        actionButtonIconName={actionButtonIconName}
        secondaryActions={
          <Box padding={{ left: 'xxs', top: 'xs' }}>
            <ButtonGroup
              ariaLabel="Additional chat input actions"
              items={[
                {
                  type: 'icon-button',
                  id: 'upload-files',
                  iconName: 'upload',
                  text: 'Upload files',
                },
                {
                  type: 'icon-button',
                  id: 'add-reference',
                  iconName: 'at-symbol',
                  text: 'Add reference or citation',
                },
              ]}
              variant="icon"
            />
          </Box>
        }
      />
      <Box fontSize="body-s" color="text-body-secondary">
        Use of this service is subject to the{' '}
        <Link external variant="primary" href="https://aws.amazon.com/machine-learning/responsible-ai/policy/">
          AWS Responsible AI Policy
        </Link>
      </Box>
    </SpaceBetween>
  );
};

/** Region that holds the chat, tall enough to keep the prompt input in place while messages load. */
const chatRegionStyle: CSSProperties = {
  minBlockSize: 280,
};

/**
 * Aligns content placed under a chat bubble (actions, artifacts, follow-up prompts) with
 * the bubble text: the avatar width (28px) plus the gap between avatar and bubble.
 */
const chatBubbleIndentationStyle: CSSProperties = {
  marginInlineStart: `calc(28px + ${spaceScaledXs})`,
};

const pythonCode = `def lambda_handler(event, context):
    bucket = event['Records'][0]['s3']['bucket']['name']
    key = event['Records'][0]['s3']['object']['key']
    print(f"New file uploaded: {key} in bucket {bucket}")
    return {'statusCode': 200}`;

export default function GenAiArtifactPreviewCodeSnippets() {
  return (
    <Container
      header={<Header variant="h3">AI assistant</Header>}
      footer={<CustomGenAIChatFooter actionButtonIconName="send" actionButtonAriaLabel="Send message" />}
    >
      <div role="region" aria-label="Chat" style={chatRegionStyle}>
        <SpaceBetween size="xs">
          <ChatBubble type="outgoing" ariaLabel={`${userName} at 05:37:30pm`} avatar={userAvatar}>
            Show me the simplest Lambda function to log S3 uploads
          </ChatBubble>

          <ChatBubble type="incoming" ariaLabel={`${genAiName} at 05:37:35pm`} avatar={genAiAvatar}>
            Here is a snippet of the simplest Lambda function to log S3 uploads.
          </ChatBubble>

          <div style={chatBubbleIndentationStyle}>
            <ItemCard
              variant="embedded"
              header={
                <Box fontSize="heading-xs" fontWeight="bold">
                  Python
                </Box>
              }
              actions={
                <SpaceBetween direction="horizontal" size="xxs">
                  <Button iconName="download" variant="icon" ariaLabel="Download code" />
                  <CopyToClipboard
                    copyButtonText="Copy"
                    copyErrorText="Code failed to copy"
                    copySuccessText="Code copied"
                    textToCopy={pythonCode}
                    variant="icon"
                  />
                </SpaceBetween>
              }
            >
              <CodeView content={pythonCode} highlight={pythonHighlight} ariaLabel="Python Lambda function" />
            </ItemCard>
          </div>
        </SpaceBetween>
      </div>
    </Container>
  );
}
```

### Media

Generated media such as images, charts, diagrams, or videos display with inline previews using [item card](/components/item-card/index.html.md) . These cab include file names, metadata, and actions for downloading or expanding. This allows users to immediately view and assess visual content without requiring them to be opened in a separate viewer. For expanding a generated artifact such as an image, follow the guidance for [image magnifier](/patterns/general/image-magnifier/index.html.md).

### AI assistant

JD Create an image of a happy corgi dog. Here you go - an image of a happy corgi dog. dog-portrait.jpg 886 × 408 - 487 KB Use of this service is subject to the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/)
```genai-artifact-preview-media.tsx
import React, { type CSSProperties } from 'react';
import ChatBubble from '@cloudscape-design/chat-components/chat-bubble';
import Button from '@cloudscape-design/components/button';
import Box from '@cloudscape-design/components/box';
import Container from '@cloudscape-design/components/container';
import Header from '@cloudscape-design/components/header';
import ItemCard from '@cloudscape-design/components/item-card';
import SpaceBetween from '@cloudscape-design/components/space-between';
import { borderRadiusCardEmbedded, spaceScaledM, spaceScaledXs } from '@cloudscape-design/design-tokens/index.js';
import Avatar from '@cloudscape-design/chat-components/avatar';
import PromptInput from '@cloudscape-design/components/prompt-input';
import ButtonGroup from '@cloudscape-design/components/button-group';
import Link from '@cloudscape-design/components/link';
import { IconProps } from '@cloudscape-design/components/icon';

const userName = 'John Doe';
const genAiName = 'AI assistant';
const genAiAvatarAriaLabel = 'Avatar of AI assistant';

const userAvatar = <Avatar ariaLabel={`Avatar of ${userName}`} initials="JD" tooltipText={userName} />;

const genAiAvatar = (
  <Avatar ariaLabel={genAiAvatarAriaLabel} color="gen-ai" iconName="gen-ai" tooltipText={genAiName} />
);

const CustomGenAIChatFooter = ({
  actionButtonIconName,
  actionButtonAriaLabel,
  message,
  onSendMessage,
  onAction,
}: {
  actionButtonIconName: IconProps.Name;
  actionButtonAriaLabel: string;
  message?: string;
  onSendMessage?: (text: string) => void;
  onAction?: (text: string) => void;
}) => {
  return (
    <SpaceBetween size="xs">
      <PromptInput
        value={message ?? ''}
        onChange={({ detail }) => onSendMessage?.(detail.value)}
        onAction={({ detail }) => onAction?.(detail.value)}
        disableSecondaryActionsPaddings
        actionButtonAriaLabel={actionButtonAriaLabel}
        actionButtonIconName={actionButtonIconName}
        secondaryActions={
          <Box padding={{ left: 'xxs', top: 'xs' }}>
            <ButtonGroup
              ariaLabel="Additional chat input actions"
              items={[
                {
                  type: 'icon-button',
                  id: 'upload-files',
                  iconName: 'upload',
                  text: 'Upload files',
                },
                {
                  type: 'icon-button',
                  id: 'add-reference',
                  iconName: 'at-symbol',
                  text: 'Add reference or citation',
                },
              ]}
              variant="icon"
            />
          </Box>
        }
      />
      <Box fontSize="body-s" color="text-body-secondary">
        Use of this service is subject to the{' '}
        <Link external variant="primary" href="https://aws.amazon.com/machine-learning/responsible-ai/policy/">
          AWS Responsible AI Policy
        </Link>
      </Box>
    </SpaceBetween>
  );
};

/** Region that holds the chat, tall enough to keep the prompt input in place while messages load. */
const chatRegionStyle: CSSProperties = {
  minBlockSize: 280,
};

/**
 * Aligns content placed under a chat bubble (actions, artifacts, follow-up prompts) with
 * the bubble text: the avatar width (28px) plus the gap between avatar and bubble.
 */
const chatBubbleIndentationStyle: CSSProperties = {
  marginInlineStart: `calc(28px + ${spaceScaledXs})`,
};

export default function GenAiArtifactPreviewMedia() {
  return (
    <Container
      header={<Header variant="h3">AI assistant</Header>}
      footer={<CustomGenAIChatFooter actionButtonIconName="send" actionButtonAriaLabel="Send message" />}
    >
      <div role="region" aria-label="Chat" style={chatRegionStyle}>
        <SpaceBetween size="xs">
          <ChatBubble type="outgoing" ariaLabel={`${userName} at 05:37:30pm`} avatar={userAvatar}>
            Create an image of a happy corgi dog.
          </ChatBubble>

          <ChatBubble type="incoming" ariaLabel={`${genAiName} at 05:37:35pm`} avatar={genAiAvatar}>
            Here you go – an image of a happy corgi dog.
          </ChatBubble>

          <div style={{ ...chatBubbleIndentationStyle, maxInlineSize: 500 }}>
            <ItemCard
              variant="embedded"
              header={
                <Box fontSize="heading-xs" fontWeight="bold">
                  dog-portrait.jpg
                </Box>
              }
              description="886 × 408 – 487 KB"
              disableContentPaddings
              actions={
                <SpaceBetween direction="horizontal" size="xxs">
                  <Button iconName="download" variant="icon" ariaLabel="Download image" />
                  <Button iconName="expand" variant="icon" ariaLabel="View fullscreen" />
                </SpaceBetween>
              }
            >
              <div
                style={{
                  paddingBlockStart: spaceScaledM,
                  overflow: 'hidden',
                  borderEndStartRadius: borderRadiusCardEmbedded,
                  borderEndEndRadius: borderRadiusCardEmbedded,
                }}
              >
                <img
                  src="/a-portrait-of-a-happy-corgi-dog.jpg"
                  alt="A portrait of a happy corgi dog"
                  style={{ inlineSize: '100%', display: 'block' }}
                />
              </div>
            </ItemCard>
          </div>
        </SpaceBetween>
      </div>
    </Container>
  );
}
```

### Download-only files

Documents and generated files display as downloadable artifacts using [item card](/components/item-card/index.html.md) with file names, size metadata, and download actions. This format works for well any files that users need to save locally without opening or viewing them first.

### AI assistant

JD Please create a .csv of my monthly budget with categories and expenses Here is a .csv with your monthly budget and expenses. Let me know if you need any changes to the format or categories. jd-budget.csv 1.82 MB Use of this service is subject to the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/)
```genai-artifact-preview-download-only-files.tsx
import React, { type CSSProperties } from 'react';
import ChatBubble from '@cloudscape-design/chat-components/chat-bubble';
import Button from '@cloudscape-design/components/button';
import Box from '@cloudscape-design/components/box';
import Container from '@cloudscape-design/components/container';
import Header from '@cloudscape-design/components/header';
import Icon, { IconProps } from '@cloudscape-design/components/icon';
import ItemCard from '@cloudscape-design/components/item-card';
import SpaceBetween from '@cloudscape-design/components/space-between';
import Avatar from '@cloudscape-design/chat-components/avatar';
import ButtonGroup from '@cloudscape-design/components/button-group';
import StatusIndicator from '@cloudscape-design/components/status-indicator';
import PromptInput from '@cloudscape-design/components/prompt-input';
import Link from '@cloudscape-design/components/link';
import { spaceScaledXs } from '@cloudscape-design/design-tokens/index.js';

const userName = 'John Doe';
const genAiName = 'AI assistant';
const genAiAvatarAriaLabel = 'Avatar of AI assistant';

const userAvatar = <Avatar ariaLabel={`Avatar of ${userName}`} initials="JD" tooltipText={userName} />;

const genAiAvatar = (
  <Avatar ariaLabel={genAiAvatarAriaLabel} color="gen-ai" iconName="gen-ai" tooltipText={genAiName} />
);

const chatBubbleActions = (
  <ButtonGroup
    ariaLabel="Chat bubble actions"
    variant="icon"
    items={[
      {
        type: 'group',
        text: 'Feedback',
        items: [
          {
            type: 'icon-button',
            id: 'helpful',
            iconName: 'thumbs-up',
            text: 'Helpful',
          },
          {
            type: 'icon-button',
            id: 'not-helpful',
            iconName: 'thumbs-down',
            text: 'Not helpful',
          },
        ],
      },
      {
        type: 'group',
        text: 'actions',
        items: [
          {
            type: 'icon-button',
            id: 'copy',
            iconName: 'copy',
            text: 'Copy',
            popoverFeedback: <StatusIndicator type="success">Message copied</StatusIndicator>,
          },
          {
            type: 'icon-button',
            id: 'refresh',
            iconName: 'refresh',
            text: 'Regenerate',
          },
        ],
      },
    ]}
  />
);

const CustomGenAIChatFooter = ({
  actionButtonIconName,
  actionButtonAriaLabel,
  message,
  onSendMessage,
  onAction,
}: {
  actionButtonIconName: IconProps.Name;
  actionButtonAriaLabel: string;
  message?: string;
  onSendMessage?: (text: string) => void;
  onAction?: (text: string) => void;
}) => {
  return (
    <SpaceBetween size="xs">
      <PromptInput
        value={message ?? ''}
        onChange={({ detail }) => onSendMessage?.(detail.value)}
        onAction={({ detail }) => onAction?.(detail.value)}
        disableSecondaryActionsPaddings
        actionButtonAriaLabel={actionButtonAriaLabel}
        actionButtonIconName={actionButtonIconName}
        secondaryActions={
          <Box padding={{ left: 'xxs', top: 'xs' }}>
            <ButtonGroup
              ariaLabel="Additional chat input actions"
              items={[
                {
                  type: 'icon-button',
                  id: 'upload-files',
                  iconName: 'upload',
                  text: 'Upload files',
                },
                {
                  type: 'icon-button',
                  id: 'add-reference',
                  iconName: 'at-symbol',
                  text: 'Add reference or citation',
                },
              ]}
              variant="icon"
            />
          </Box>
        }
      />
      <Box fontSize="body-s" color="text-body-secondary">
        Use of this service is subject to the{' '}
        <Link external variant="primary" href="https://aws.amazon.com/machine-learning/responsible-ai/policy/">
          AWS Responsible AI Policy
        </Link>
      </Box>
    </SpaceBetween>
  );
};

/** Region that holds the chat, tall enough to keep the prompt input in place while messages load. */
const chatRegionStyle: CSSProperties = {
  minBlockSize: 280,
};

/**
 * Aligns content placed under a chat bubble (actions, artifacts, follow-up prompts) with
 * the bubble text: the avatar width (28px) plus the gap between avatar and bubble.
 */
const chatBubbleIndentationStyle: CSSProperties = {
  marginInlineStart: `calc(28px + ${spaceScaledXs})`,
};

export default function GenAiArtifactPreviewDownloadOnlyFiles() {
  return (
    <Container
      header={<Header variant="h3">AI assistant</Header>}
      footer={<CustomGenAIChatFooter actionButtonIconName="send" actionButtonAriaLabel="Send message" />}
    >
      <div role="region" aria-label="Chat" style={chatRegionStyle}>
        <SpaceBetween size="xs">
          <ChatBubble type="outgoing" ariaLabel={`${userName} at 05:37:30pm`} avatar={userAvatar}>
            Please create a .csv of my monthly budget with categories and expenses
          </ChatBubble>

          <ChatBubble
            type="incoming"
            ariaLabel={`${genAiName} at 05:37:35pm`}
            avatar={genAiAvatar}
            actions={chatBubbleActions}
          >
            Here is a .csv with your monthly budget and expenses. Let me know if you need any changes to the format or
            categories.
          </ChatBubble>

          <div style={{ ...chatBubbleIndentationStyle, inlineSize: 'fit-content' }}>
            <ItemCard
              variant="embedded"
              icon={<Icon name="file" />}
              header={
                <Box fontSize="heading-xs" fontWeight="bold">
                  jd-budget.csv
                </Box>
              }
              description="1.82 MB"
              actions={<Button iconName="download" variant="icon" ariaLabel="Download file" />}
            />
          </div>
        </SpaceBetween>
      </div>
    </Container>
  );
}
```

## Canvas previews

### Selectable preview

Artifact previews allow users to interact with generated content and progressively render the full artifact in an adjacent panel using an [action card](/components/action-card/index.html.md) . For example, when a user selects an AI-generated document artifact preview, its contents display in the side panel. Use when users need to preview or read through content as the primary action without requiring secondary actions such as download or share.

### AI assistant

JD Write an architecture overview for our multi-region deployment strategy I've drafted an architecture overview covering multi-region topology, data replication, failover strategy, and observability for your deployment. multi-region-architecture.md 18.7 KB Use of this service is subject to the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/)
### multi-region-architecture.md

#### Multi-Region Architecture Overview

This document describes the architecture for deploying the application across multiple AWS Regions to improve availability, reduce latency, and meet data residency requirements.

#### Regional topology

The primary Region is us-east-1, with active-active deployments in eu-west-1 and ap-southeast-1. Each Region runs an independent stack consisting of an Application Load Balancer, Amazon ECS services on Fargate, and a Regional Amazon DynamoDB table with global tables enabled.

#### Traffic routing

Amazon Route 53 latency-based routing directs users to the nearest healthy Region. Health checks monitor the ALB endpoint in each Region with a 10-second interval and 3-failure threshold before failover. DNS TTL is set to 60 seconds to allow rapid rerouting during incidents.

#### Data replication

1. **DynamoDB global tables**   - Provides multi-Region, multi-active replication with eventual consistency. Conflict resolution uses last-writer-wins based on item timestamps.
2. **Amazon S3 cross-Region replication**   - Static assets and user uploads replicate from the primary bucket to Regional buckets with replication time control (RTC) for predictable 15-minute SLA.
3. **Amazon ElastiCache Global Datastore**   - Session data replicates across Regions with sub-second lag, enabling seamless failover without session loss.

#### Failover strategy

Automated failover is handled at the DNS layer through Route 53 health checks. If a Region becomes unhealthy, traffic shifts to the next-lowest-latency Region within 60-90 seconds. Manual failover is available through a runbook that updates Route 53 routing policies and disables the affected Region's ECS services.

#### Observability

Each Region publishes metrics to a centralized Amazon CloudWatch dashboard in us-east-1 using cross-account observability. Key metrics include request latency (p50, p99), error rates, DynamoDB replication lag, and ECS task health. CloudWatch alarms trigger SNS notifications and automatically create incident tickets when thresholds are breached.

#### Cost considerations

Multi-Region deployment increases infrastructure costs by approximately 2.4x compared to a single Region. The primary cost drivers are cross-Region data transfer, DynamoDB global table write capacity, and redundant compute in each Region. Reserved capacity and Savings Plans are applied across all Regions to reduce baseline costs by 30-40%.

```genai-artifact-preview-selectable-preview.tsx
import React, { useState, type CSSProperties } from 'react';
import ChatBubble from '@cloudscape-design/chat-components/chat-bubble';
import ActionCard from '@cloudscape-design/components/action-card';
import Box from '@cloudscape-design/components/box';
import Button from '@cloudscape-design/components/button';
import Header from '@cloudscape-design/components/header';
import Icon, { IconProps } from '@cloudscape-design/components/icon';
import SpaceBetween from '@cloudscape-design/components/space-between';
import TextContent from '@cloudscape-design/components/text-content';
import {
  borderRadiusContainer,
  colorBackgroundContainerContent,
  colorBorderDividerDefault,
  motionDurationResponsive,
  motionEasingResponsive,
  spaceContainerHorizontal,
  spaceScaledL,
  spaceScaledM,
  spaceScaledXs,
} from '@cloudscape-design/design-tokens/index.js';
import Avatar from '@cloudscape-design/chat-components/avatar';
import PromptInput from '@cloudscape-design/components/prompt-input';
import ButtonGroup from '@cloudscape-design/components/button-group';
import Link from '@cloudscape-design/components/link';

const userName = 'John Doe';
const genAiName = 'AI assistant';
const genAiAvatarAriaLabel = 'Avatar of AI assistant';

const userAvatar = <Avatar ariaLabel={`Avatar of ${userName}`} initials="JD" tooltipText={userName} />;

const genAiAvatar = (
  <Avatar ariaLabel={genAiAvatarAriaLabel} color="gen-ai" iconName="gen-ai" tooltipText={genAiName} />
);

const CustomGenAIChatFooter = ({
  actionButtonIconName,
  actionButtonAriaLabel,
  message,
  onSendMessage,
  onAction,
}: {
  actionButtonIconName: IconProps.Name;
  actionButtonAriaLabel: string;
  message?: string;
  onSendMessage?: (text: string) => void;
  onAction?: (text: string) => void;
}) => {
  return (
    <SpaceBetween size="xs">
      <PromptInput
        value={message ?? ''}
        onChange={({ detail }) => onSendMessage?.(detail.value)}
        onAction={({ detail }) => onAction?.(detail.value)}
        disableSecondaryActionsPaddings
        actionButtonAriaLabel={actionButtonAriaLabel}
        actionButtonIconName={actionButtonIconName}
        secondaryActions={
          <Box padding={{ left: 'xxs', top: 'xs' }}>
            <ButtonGroup
              ariaLabel="Additional chat input actions"
              items={[
                {
                  type: 'icon-button',
                  id: 'upload-files',
                  iconName: 'upload',
                  text: 'Upload files',
                },
                {
                  type: 'icon-button',
                  id: 'add-reference',
                  iconName: 'at-symbol',
                  text: 'Add reference or citation',
                },
              ]}
              variant="icon"
            />
          </Box>
        }
      />
      <Box fontSize="body-s" color="text-body-secondary">
        Use of this service is subject to the{' '}
        <Link external variant="primary" href="https://aws.amazon.com/machine-learning/responsible-ai/policy/">
          AWS Responsible AI Policy
        </Link>
      </Box>
    </SpaceBetween>
  );
};

/**
 * Aligns content placed under a chat bubble (actions, artifacts, follow-up prompts) with
 * the bubble text: the avatar width (28px) plus the gap between avatar and bubble.
 */
const chatBubbleIndentationStyle: CSSProperties = {
  marginInlineStart: `calc(28px + ${spaceScaledXs})`,
};

const divider = `1px solid ${colorBorderDividerDefault}`;

const layoutStyle: React.CSSProperties = {
  display: 'flex',
  blockSize: 580,
  border: divider,
  borderRadius: borderRadiusContainer,
  overflow: 'hidden',
};

const chatPanelStyle: React.CSSProperties = {
  display: 'flex',
  flexDirection: 'column',
  flex: '1 1 auto',
  minInlineSize: 0,
  background: colorBackgroundContainerContent,
};

const getArtifactPanelStyle = (open: boolean): React.CSSProperties => ({
  flex: open ? '0 0 58%' : '0 0 0',
  overflow: open ? 'auto' : 'hidden',
  borderInlineStart: open ? divider : undefined,
  background: colorBackgroundContainerContent,
  transition: `flex ${motionDurationResponsive} ${motionEasingResponsive}`,
});

export default function GenAiArtifactPreviewSelectablePreview() {
  const [artifactOpen, setArtifactOpen] = useState(false);

  return (
    <div style={layoutStyle}>
      <div style={chatPanelStyle}>
        <div style={{ padding: `${spaceScaledL} ${spaceContainerHorizontal} ${spaceScaledXs}` }}>
          <Header variant="h3">AI assistant</Header>
        </div>

        <div
          style={{ flex: 1, overflow: 'auto', padding: `${spaceScaledM} ${spaceContainerHorizontal}` }}
          role="region"
          aria-label="Chat"
        >
          <SpaceBetween size="xs">
            <ChatBubble type="outgoing" ariaLabel={`${userName} at 05:37:30pm`} avatar={userAvatar}>
              Write an architecture overview for our multi-region deployment strategy
            </ChatBubble>

            <ChatBubble type="incoming" ariaLabel={`${genAiName} at 05:37:35pm`} avatar={genAiAvatar}>
              I&apos;ve drafted an architecture overview covering multi-region topology, data replication, failover
              strategy, and observability for your deployment.
            </ChatBubble>

            <div style={{ ...chatBubbleIndentationStyle, inlineSize: 'fit-content' }}>
              <ActionCard
                variant="embedded"
                header={
                  <Box fontSize="heading-xs" fontWeight="bold">
                    multi-region-architecture.md
                  </Box>
                }
                description="18.7 KB"
                icon={<Icon name="arrow-right" />}
                onClick={() => setArtifactOpen(true)}
                ariaLabel="Open multi-region architecture preview"
              />
            </div>
          </SpaceBetween>
        </div>

        <div style={{ borderBlockStart: divider, padding: `${spaceScaledL} ${spaceContainerHorizontal}` }}>
          <CustomGenAIChatFooter actionButtonIconName="send" actionButtonAriaLabel="Send message" />
        </div>
      </div>

      <div
        style={getArtifactPanelStyle(artifactOpen)}
        aria-hidden={!artifactOpen}
        inert={!artifactOpen ? true : undefined}
      >
        <Box padding="l">
          <SpaceBetween size="m">
            <Header
              variant="h3"
              actions={
                <SpaceBetween direction="horizontal" size="xxs">
                  <Button iconName="share" variant="icon" ariaLabel="Share document" />
                  <Button iconName="download" variant="icon" ariaLabel="Download document" />
                  <Button
                    iconName="close"
                    variant="icon"
                    ariaLabel="Close artifact"
                    onClick={() => setArtifactOpen(false)}
                  />
                </SpaceBetween>
              }
            >
              multi-region-architecture.md
            </Header>
            <TextContent>
              <h4>Multi-Region Architecture Overview</h4>
              <p>
                This document describes the architecture for deploying the application across multiple AWS Regions to
                improve availability, reduce latency, and meet data residency requirements.
              </p>
              <h4>Regional topology</h4>
              <p>
                The primary Region is us-east-1, with active-active deployments in eu-west-1 and ap-southeast-1. Each
                Region runs an independent stack consisting of an Application Load Balancer, Amazon ECS services on
                Fargate, and a Regional Amazon DynamoDB table with global tables enabled.
              </p>
              <h4>Traffic routing</h4>
              <p>
                Amazon Route 53 latency-based routing directs users to the nearest healthy Region. Health checks monitor
                the ALB endpoint in each Region with a 10-second interval and 3-failure threshold before failover. DNS
                TTL is set to 60 seconds to allow rapid rerouting during incidents.
              </p>
              <h4>Data replication</h4>
              <ol>
                <li>
                  <strong>DynamoDB global tables</strong> — Provides multi-Region, multi-active replication with
                  eventual consistency. Conflict resolution uses last-writer-wins based on item timestamps.
                </li>
                <li>
                  <strong>Amazon S3 cross-Region replication</strong> — Static assets and user uploads replicate from
                  the primary bucket to Regional buckets with replication time control (RTC) for predictable 15-minute
                  SLA.
                </li>
                <li>
                  <strong>Amazon ElastiCache Global Datastore</strong> — Session data replicates across Regions with
                  sub-second lag, enabling seamless failover without session loss.
                </li>
              </ol>
              <h4>Failover strategy</h4>
              <p>
                Automated failover is handled at the DNS layer through Route 53 health checks. If a Region becomes
                unhealthy, traffic shifts to the next-lowest-latency Region within 60–90 seconds. Manual failover is
                available through a runbook that updates Route 53 routing policies and disables the affected
                Region&apos;s ECS services.
              </p>
              <h4>Observability</h4>
              <p>
                Each Region publishes metrics to a centralized Amazon CloudWatch dashboard in us-east-1 using
                cross-account observability. Key metrics include request latency (p50, p99), error rates, DynamoDB
                replication lag, and ECS task health. CloudWatch alarms trigger SNS notifications and automatically
                create incident tickets when thresholds are breached.
              </p>
              <h4>Cost considerations</h4>
              <p>
                Multi-Region deployment increases infrastructure costs by approximately 2.4x compared to a single
                Region. The primary cost drivers are cross-Region data transfer, DynamoDB global table write capacity,
                and redundant compute in each Region. Reserved capacity and Savings Plans are applied across all Regions
                to reduce baseline costs by 30–40%.
              </p>
            </TextContent>
          </SpaceBetween>
        </Box>
      </div>
    </div>
  );
}
```

## General guidelines

### Do

- Maintain a clear separation between actions that belong to the artifacts generated by AI and the conversation. For example, group actions related to the artifact preview within its card and the actions related to the [chat bubble in a button group](/components/chat-bubble/index.html.md)  .
- When an inline artifact preview has multiple actions, consolidate them into a single button dropdown with a   ellipsis   icon to reduce visual clutter and maintain a clean interface.

### Don't

- Don't nest artifacts into a chat bubble. Stack each artifact to ensure clarity and improve readability. For more detailed guidance on message structure and stacking patterns, refer to the [generative AI chat pattern](/gen-ai/patterns/generative-ai-chat/index.html.md)  .

## Writing guidelines

### General writing guidelines

- Use sentence case, but continue to capitalize proper nouns and brand names correctly in context.
- Use end punctuation, except in [headers](/components/header/index.html.md)   and [buttons](/components/button/index.html.md)   . Don't use exclamation points.
- Use present-tense verbs and active voice.
- Don't use *please*   , *thank you*   , ellipsis ( *...*   ), ampersand ( *&*   ), *e.g.*   , *i.e.*   , or *etc.*   in writing.
- Avoid directional language.  

  - For example: use *previous*     not *above*     , use *following*     not *below*    .
- Use device-independent language.  

  - For example: use *choose*     or *select*     not *click*    .

### Component-specific guidelines

#### Artifact metadata

- Express the file size using standard units such as KB, MB, or GB.

## Accessibility guidelines

### General accessibility guidelines

- Follow the guidelines on alternative text and Accessible Rich Internet Applications (ARIA) regions for each component.
- Make sure to define ARIA labels aligned with the language context of your application.
- Don't add unnecessary markup for roles and landmarks. Follow the guidelines for each component.
- Provide keyboard functionality to all available content in a logical and predictable order. The flow of information should make sense.






## Search Cloudscape