PeakUIPro

PromptSuggestion

Suggested prompts and starter cards for chat empty states

Usage

import {PromptSuggestion} from "@peakui-pro/react";

Anatomy

import {PromptSuggestion} from "@peakui-pro/react";

export default () => (
  <PromptSuggestion>
    <PromptSuggestion.Header>
      <PromptSuggestion.Title>What can I help with?</PromptSuggestion.Title>
      <PromptSuggestion.Description>Start from a suggested prompt.</PromptSuggestion.Description>
    </PromptSuggestion.Header>
    {/* A plain div: `role` and `aria-label` are yours to add. */}
    <PromptSuggestion.Items aria-label="Suggested prompts" role="group">
      <PromptSuggestion.Item>
        <PromptSuggestion.ItemTitle>Summarize this document</PromptSuggestion.ItemTitle>
        <PromptSuggestion.ItemDescription>Create a concise summary.</PromptSuggestion.ItemDescription>
        <PromptSuggestion.ItemMeta>Used 12 times this week</PromptSuggestion.ItemMeta>
        <PromptSuggestion.ItemTags>...</PromptSuggestion.ItemTags>
        <PromptSuggestion.ItemFooter>About 2 minutes</PromptSuggestion.ItemFooter>
      </PromptSuggestion.Item>
    </PromptSuggestion.Items>
  </PromptSuggestion>
);

Examples

Cards

variant="card" lays the item slots out as cards in a grid.

Cards With All Slots

Compose ItemMeta, ItemTags and ItemFooter after the title and description.

Named Group

Items has no group semantics by default; add role="group" and a label.

Disabled

isDisabled dims one suggestion and takes it out of the tab order.

Press Handler

onPress hands the host the chosen prompt, to send to a composer.

Customization

Tailwind CSS

<PromptSuggestion className="[--prompt-suggestion-gap:1.5rem] [--prompt-suggestion-pill-radius:var(--radius-xl)]">
  <PromptSuggestion.Items aria-label="Suggested prompts" role="group">
    <PromptSuggestion.Item>Draft a weekly project update email</PromptSuggestion.Item>
  </PromptSuggestion.Items>
</PromptSuggestion>

Global CSS

@layer components {
  .prompt-suggestion {
    --prompt-suggestion-gap: 1.5rem;
    --prompt-suggestion-pill-radius: var(--radius-xl);
  }

  .prompt-suggestion--card {
    --prompt-suggestion-card-min-width: 18rem;
    --prompt-suggestion-card-padding: 1.25rem;
  }
}

Styling Reference

PeakUI follows the BEM methodology, so variants and states are plain class names you can target.

CSS Classes

The PromptSuggestion component uses these CSS classes (view source styles):

Base Classes

  • .prompt-suggestion - Root
  • .prompt-suggestion--pill - Default layout: a grid of two columns, then one
  • .prompt-suggestion--card - Card layout: a grid that adds columns as the width allows

Element Classes

  • .prompt-suggestion__header - Title and description wrapper
  • .prompt-suggestion__title - Header title
  • .prompt-suggestion__description - Header description
  • .prompt-suggestion__items - Suggestion grid
  • .prompt-suggestion__item - One suggestion, beside the core .button classes
  • .prompt-suggestion__item-label - Pill text wrapper
  • .prompt-suggestion__item-end-icon - Pill chevron
  • .prompt-suggestion__item-title - Card title
  • .prompt-suggestion__item-description - Card description
  • .prompt-suggestion__item-meta - Card meta line
  • .prompt-suggestion__item-tags - Card tag row
  • .prompt-suggestion__item-footer - Card footer

Modifier Classes

  • .prompt-suggestion__items--pill, .prompt-suggestion__items--card - Grid per layout
  • .prompt-suggestion__item--pill, .prompt-suggestion__item--card - Item per layout

Slots

  • [data-slot="prompt-suggestion"]
  • [data-slot="prompt-suggestion-header"]
  • [data-slot="prompt-suggestion-title"]
  • [data-slot="prompt-suggestion-description"]
  • [data-slot="prompt-suggestion-items"]
  • [data-slot="prompt-suggestion-item"]
  • [data-slot="prompt-suggestion-item-label"]
  • [data-slot="prompt-suggestion-item-end-icon"]
  • [data-slot="prompt-suggestion-item-title"]
  • [data-slot="prompt-suggestion-item-description"]
  • [data-slot="prompt-suggestion-item-meta"]
  • [data-slot="prompt-suggestion-item-tags"]
  • [data-slot="prompt-suggestion-item-footer"]

CSS Variables

VariablePurpose
--prompt-suggestion-gapSpace between the header and the items; defaults to 2rem
--prompt-suggestion-items-gapSpace between items; defaults to 0.5rem, 0.75rem in the card layout
--prompt-suggestion-pill-min-widthNarrowest pill column; defaults to 18rem
--prompt-suggestion-pill-radiusPill corner radius; defaults to var(--radius-2xl)
--prompt-suggestion-card-min-widthNarrowest card column; defaults to 14rem
--prompt-suggestion-card-paddingCard padding; defaults to 1rem
--prompt-suggestion-card-radiusCard corner radius; defaults to var(--radius-2xl)

Interactive States

The item is the core button and takes its states:

  • Hover: :hover or [data-hovered]
  • Pressed: :active or [data-pressed], scaled to 0.97 by the core button
  • Focus: :focus-visible or [data-focus-visible]
  • Disabled: :disabled, [data-disabled] or [aria-disabled="true"], dimmed by the core button
  • Forced colors: @media (forced-colors: active) paints the chevron and the card text in ButtonText, so an enabled item never reads as disabled

API Reference

PromptSuggestion

PropTypeDefaultDescription
variant'pill' | 'card''pill'Layout: a grid of short prompts with a chevron, or a grid of cards that compose the item slots
classNamestring-Additional classes
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div> with your own element
...restComponentProps<'div'>-Native <div> attributes

PromptSuggestion.Header

PropTypeDefaultDescription
classNamestring-Additional classes
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div> with your own element
...restComponentProps<'div'>-Native <div> attributes

PromptSuggestion.Title

PropTypeDefaultDescription
classNamestring-Additional classes
renderDOMRenderFunction<'h2', undefined>-Replaces the rendered <h2>, to set the heading level your page needs
...restComponentProps<'h2'>-Native <h2> attributes

PromptSuggestion.Description

PropTypeDefaultDescription
classNamestring-Additional classes
renderDOMRenderFunction<'p', undefined>-Replaces the rendered <p> with your own element
...restComponentProps<'p'>-Native <p> attributes

PromptSuggestion.Items

PropTypeDefaultDescription
classNamestring-Additional classes
rolestring-None by default; pass "group" with aria-label so a screen reader announces the set
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div> with your own element
...restComponentProps<'div'>-Native <div> attributes

PromptSuggestion.Item

PropTypeDefaultDescription
childrenReact.ReactNode | (values: ButtonRenderProps) => React.ReactNode-The prompt text, or the item slots in the card layout. The accessible name is the whole content, not the title alone
variant'primary' | 'secondary' | 'tertiary' | 'outline' | 'ghost' | 'danger' | 'danger-soft''outline'Core button style, which sets only the fill and the border: the item always sets its text to the foreground colour. In pill, outline, ghost, secondary, tertiary and danger-soft work; primary and danger put that text on a solid fill, under 4.5:1 in the light theme, so do not use them. In card, none works: the surface fill and the surface shadow are fixed and every variant renders alike
isDisabledbooleanfalseWhether the suggestion is disabled
onPress(e: PressEvent) => void-Handler called when the suggestion is pressed
classNamestring | (values: ButtonRenderProps) => string-Additional classes, or a function of the button's state
renderDOMRenderFunction<'button', ButtonRenderProps>-Replaces the rendered element; receives the props with data-slot set
...restButtonProps-Every other core Button prop

PromptSuggestion.ItemTitle, ItemDescription, ItemMeta, ItemTags, ItemFooter

PropTypeDefaultDescription
classNamestring-Additional classes
renderDOMRenderFunction<'span', undefined>-Replaces the rendered <span>; the slots are spans because a button holds phrasing content only
...restComponentProps<'span'>-Native <span> attributes

Render Props

PropTypeDescription
isPendingbooleanWhether the item is waiting on an operation
isPressedbooleanWhether the item is currently pressed
isHoveredbooleanWhether the item is hovered
isFocusedbooleanWhether the item is focused
isFocusVisiblebooleanWhether the item is focused by keyboard
isDisabledbooleanWhether the item is disabled

On this page