# Chat Welcome

> Open a new conversation with a greeting, what the assistant can do, a composer, and prompts to start from.

Source: https://www.honestui.com/docs/ai/chat-welcome

```tsx
"use client"

import * as React from "react"
import {
  ChartLine as ChartLineIcon,
  Mail as MailIcon,
  Search as SearchIcon,
  Sparkles as SparklesIcon,
} from "honestui/icons"

import { ChatWelcome } from "@/components/ai/chat-welcome"
import type { PromptSuggestion } from "@/components/ai/prompt-suggestions"
import { PromptBar } from "@/components/ai/prompt-bar"

// Sample prompt starters.
const sampleSuggestions: PromptSuggestion[] = [
  { id: "late", label: "Find late invoices", icon: <SearchIcon /> },
  { id: "trend", label: "Chart this month's revenue", icon: <ChartLineIcon /> },
  { id: "email", label: "Draft a payment reminder", icon: <MailIcon /> },
]

/** A full-page start: greeting, composer, and starters. Nothing is sent here. */
export function ChatWelcomeDemo() {
  const [value, setValue] = React.useState("")

  return (
    <div className="w-full max-w-xl min-w-0 py-[var(--hui-space-6)]">
      <ChatWelcome
        icon={<SparklesIcon />}
        title="What should we look into?"
        description="Ask about invoices, payouts, or a failed export. Answers cite the records they come from."
        composer={
          <PromptBar
            value={value}
            onValueChange={setValue}
            placeholder="Ask about the billing export…"
            onSubmit={() => setValue("")}
          />
        }
        suggestions={sampleSuggestions}
        onSelectSuggestion={(suggestion) => setValue(suggestion.prompt)}
      />
    </div>
  )
}

```

## Overview [#overview]

Chat Welcome is what a new conversation opens on: a greeting, a line on what the assistant can help with, and a few [Prompt Suggestions](/docs/ai/prompt-suggestions) to start from.

Give it a `composer` for a full-page start, or drop it into [Chat Thread](/docs/ai/chat-thread)'s `emptyMessage`, where it gives way to the first message.

## Anatomy [#anatomy]

<Anatomy title="ChatWelcome">
  <AnatomyItem name="Icon" description="Your assistant's mark, above the title" />

  <AnatomyItem name="Title" description="The greeting" />

  <AnatomyItem name="Description" description="What the assistant can help with" />

  <AnatomyItem name="Composer" description="An optional slot, such as a Prompt Bar" />

  <AnatomyItem name="Suggestions" description="Prompt Suggestions, when you pass them" />
</Anatomy>

Installing `chat-welcome` brings [Prompt Suggestions](/docs/ai/prompt-suggestions) along.

## Behavior [#behavior]

### Suggestions [#suggestions]

Pass `suggestions` and `onSelectSuggestion` to show starters. A common choice is to put the prompt in the composer, so the person can change it before sending. `suggestionsLayout` takes the same layouts as Prompt Suggestions.

### Alignment [#alignment]

`center` suits a new chat page. `start` aligns everything to the left, for a narrow side panel.

## Accessibility [#accessibility]

The welcome is a region named by its title, which is a level-two heading. The icon is decorative. The suggestions behave as in [Prompt Suggestions](/docs/ai/prompt-suggestions#accessibility).

## Installation [#installation]


  

  
    <CliBlock commands="[&#x22;@honestai/chat-welcome&#x22;]" />
  

  
    
      
        Add the items it is built from.
      

      <CliBlock commands="[&#x22;@honestai/prompt-suggestions&#x22;]" />

      
        Copy and paste this file into your project.
      

      ### components/ai/chat-welcome.tsx

```tsx
"use client"

import * as React from "react"

import { cn } from "@/lib/utils"
import {
  PromptSuggestions,
  type PromptSuggestion,
  type PromptSuggestionsProps,
} from "@/components/ai/prompt-suggestions"

export type ChatWelcomeLabels = {
  /** Names the suggestions for screen readers. */
  suggestions: string
}

export const defaultChatWelcomeLabels: ChatWelcomeLabels = {
  suggestions: "Suggested prompts",
}

export type ChatWelcomeProps = Omit<React.ComponentProps<"section">, "title" | "children"> & {
  /** The greeting, such as "Good morning, Ana". */
  title: React.ReactNode
  /** One or two lines on what the assistant can help with. */
  description?: React.ReactNode
  /** A mark above the title: your assistant's icon or avatar. Decorative. */
  icon?: React.ReactNode
  /** Prompt starters. Leave it out to show none. */
  suggestions?: PromptSuggestion[]
  onSelectSuggestion?: PromptSuggestionsProps["onSelect"]
  /** How the suggestions are laid out. */
  suggestionsLayout?: PromptSuggestionsProps["layout"]
  /** A composer under the greeting, such as a Prompt Bar, for a full-page start. */
  composer?: React.ReactNode
  /** "center" for a new chat page, "start" for a narrow panel. */
  align?: "center" | "start"
  /** Turns the suggestions off, such as while the first reply is starting. */
  disabled?: boolean
  labels?: Partial<ChatWelcomeLabels>
}

/**
 * What a new conversation opens on: a greeting, what the assistant can do,
 * and a few prompts to start from. Drop it into ChatThread's `emptyMessage`,
 * or give it a composer for a full-page start.
 */
function ChatWelcome({
  title,
  description,
  icon,
  suggestions,
  onSelectSuggestion,
  suggestionsLayout = "wrap",
  composer,
  align = "center",
  disabled,
  labels: labelsProp,
  className,
  ...props
}: ChatWelcomeProps) {
  const labels = { ...defaultChatWelcomeLabels, ...labelsProp }
  const titleId = React.useId()
  const isCenter = align === "center"
  const hasSuggestions = Boolean(suggestions?.length && onSelectSuggestion)

  return (
    <section
      aria-labelledby={titleId}
      data-slot="chat-welcome"
      data-align={align}
      className={cn(
        "flex w-full min-w-0 flex-col gap-[var(--hui-space-7)] text-[var(--hui-color-foreground-base-primary)]",
        isCenter ? "items-center text-center" : "items-start text-left",
        className
      )}
      {...props}
    >
      <div className={cn("flex min-w-0 flex-col gap-[var(--hui-space-3)]", isCenter && "items-center")}>
        {icon && (
          <span
            aria-hidden="true"
            data-slot="chat-welcome-icon"
            className="mb-[var(--hui-space-3)] flex size-10 shrink-0 items-center justify-center rounded-[var(--hui-radius-3)] border-[0.5px] border-[var(--hui-color-border-base-primary)] bg-[var(--hui-color-background-base-primary)] text-[var(--hui-color-foreground-base-secondary)] shadow-[var(--hui-shadow-soft)] [&_svg]:size-5"
          >
            {icon}
          </span>
        )}
        <h2
          id={titleId}
          className="m-0 text-balance [font-size:var(--hui-font-size-t1)] [font-weight:var(--hui-font-weight-medium)] [letter-spacing:var(--hui-letter-spacing-t1)] [line-height:var(--hui-line-height-t1)]"
        >
          {title}
        </h2>
        {description && (
          <p
            className={cn(
              "m-0 max-w-[44ch] text-pretty text-[var(--hui-color-foreground-base-secondary)] [font-size:var(--hui-font-size-regular)] [letter-spacing:var(--hui-letter-spacing-regular)] [line-height:var(--hui-line-height-regular)]",
              isCenter && "mx-auto"
            )}
          >
            {description}
          </p>
        )}
      </div>

      {composer && (
        <div data-slot="chat-welcome-composer" className="w-full min-w-0 text-left">
          {composer}
        </div>
      )}

      {hasSuggestions && (
        <PromptSuggestions
          suggestions={suggestions!}
          onSelect={onSelectSuggestion!}
          layout={suggestionsLayout}
          disabled={disabled}
          labels={{ group: labels.suggestions }}
          className={cn(
            suggestionsLayout === "list" ? "w-full text-left" : "max-w-full",
            isCenter && suggestionsLayout === "wrap" && "justify-center"
          )}
        />
      )}
    </section>
  )
}

export { ChatWelcome }

```

      
        Update the import paths to match your project setup.
      
    
  


## Usage [#usage]

```tsx
import { ChatWelcome } from "@/components/ai/chat-welcome"
import { PromptBar } from "@/components/ai/prompt-bar"

<ChatWelcome
  title="What should we look into?"
  description="Ask about invoices, payouts, or a failed export."
  composer={<PromptBar value={draft} onValueChange={setDraft} onSubmit={send} />}
  suggestions={starters}
  onSelectSuggestion={(suggestion) => setDraft(suggestion.prompt)}
/>
```

## Examples [#examples]

### In a Chat Thread [#in-a-chat-thread]

As the thread's empty state.

```tsx
"use client"

import { ChatThread } from "@/components/ai/chat-thread"
import { ChatWelcome } from "@/components/ai/chat-welcome"

/** Inside ChatThread's empty state, the welcome gives way to the first message. */
export function ChatWelcomeThread() {
  return (
    <div className="h-80 w-full max-w-lg min-w-0">
      <ChatThread
        label="New conversation"
        emptyMessage={
          <ChatWelcome
            title="New conversation"
            description="Ask about an invoice, an export, or a failed run."
            suggestionsLayout="list"
            suggestions={[
              { id: "a", label: "Why did last night's run fail?" },
              { id: "b", label: "Summarize open invoices" },
            ]}
            onSelectSuggestion={() => {}}
          />
        }
      />
    </div>
  )
}

```

## API reference [#api-reference]

### ChatWelcome [#chatwelcome]

Accepts native section props beyond those listed.

| Prop                 | Type                           | Default    | Description                                          |
| -------------------- | ------------------------------ | ---------- | ---------------------------------------------------- |
| `title`              | `ReactNode`                    | Required   | The greeting.                                        |
| `description`        | `ReactNode`                    | None       | What the assistant can help with.                    |
| `icon`               | `ReactNode`                    | None       | A decorative mark above the title.                   |
| `suggestions`        | `PromptSuggestion[]`           | None       | Prompt starters.                                     |
| `onSelectSuggestion` | `(suggestion) => void`         | None       | Called with the chosen starter. Needed to show them. |
| `suggestionsLayout`  | `"wrap" \| "scroll" \| "list"` | `"wrap"`   | How the starters are laid out.                       |
| `composer`           | `ReactNode`                    | None       | A composer under the greeting.                       |
| `align`              | `"center" \| "start"`          | `"center"` | Centered, or aligned to the start.                   |
| `disabled`           | `boolean`                      | `false`    | Turns the starters off.                              |
| `labels`             | `Partial<ChatWelcomeLabels>`   | English    | The starters' accessible name.                       |
