Index of every page on this site: llms.txt
All skills
assistant-ui avatar

/primitives

@b0609e6
by assistant-uiassistant-ui/skills29 stars
7
Run it yourself

Builds and customizes assistant-ui chat UI from composable, unstyled @assistant-ui/react primitives: ThreadPrimitive, ComposerPrimitive (with Unstable_TriggerPopover for mentions and slash commands), MessagePrimitive and MessagePartPrimitive, ActionBarPrimitive, BranchPickerPrimitive, AttachmentPrimitive, ErrorPrimitive, AssistantModalPrimitive, ChainOfThoughtPrimitive, SelectionToolbarPrimitive, SuggestionPrimitive, QueueItemPrimitive, and the ThreadList primitives. Use when assembling or styling a custom Thread, Composer, message list, action bar, branch picker, or suggestion grid; wiring composer input, dictation, quoting, or attachments; or handling editing, branching, virtualization, scrolling, or chain of thought UI. Covers MessagePrimitive.Parts render functions per part type, groupPartByType, AuiIf in selector form, and the unstyled gotchas (AssistantRuntimeProvider, className). For prebuilt UI use setup, for the styled catalog use elements, for multi-thread sidebars use thread-list.

Use this Skill: https://skilld.dev/gh/assistant-ui/skills/primitives

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencessuggestions.md

≈1.3k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Suggestions

Suggestions supply concise starter prompts before a conversation and contextual follow ups after one. Static suggestions live in AuiConfig; runtime suggestions live in thread.suggestions.

Contents

Static suggestions

import {
  AssistantRuntimeProvider,
  AuiConfig,
  Suggestions,
} from "@assistant-ui/react";
import { useChatRuntime } from "@assistant-ui/ai-sdk";

function RuntimeProvider({ children }: { children: React.ReactNode }) {
  const runtime = useChatRuntime();
  const config = AuiConfig({
    suggestions: Suggestions([
      "Summarize this document",
      {
        title: "Plan a trip",
        label: "three days in Kyoto",
        prompt: "Plan a three day trip to Kyoto with food and transit recommendations.",
      },
    ]),
  });

  return (
    <AssistantRuntimeProvider runtime={runtime} config={config}>
      {children}
    </AssistantRuntimeProvider>
  );
}

Pass strings when the displayed text should be the sent prompt. Pass an object when a short title and optional description should stand in for a longer prompt. title falls back to prompt, and label becomes the SuggestionPrimitive.Description content. Static configuration is best for an empty thread and takes precedence over runtime values in the suggestions scope.

Suggestion primitives

import {
  AuiIf,
  SuggestionPrimitive,
  ThreadPrimitive,
} from "@assistant-ui/react";

function WelcomeSuggestions() {
  return (
    <AuiIf condition={(s) => s.thread.isEmpty}>
      <div className="grid gap-2 sm:grid-cols-2">
        <ThreadPrimitive.Suggestions>
          {() => (
            <SuggestionPrimitive.Trigger send asChild>
              <button className="rounded-lg border p-3 text-left">
                <span className="block font-medium">
                  <SuggestionPrimitive.Title />
                </span>
                <span className="block text-sm text-muted-foreground">
                  <SuggestionPrimitive.Description />
                </span>
              </button>
            </SuggestionPrimitive.Trigger>
          )}
        </ThreadPrimitive.Suggestions>
      </div>
    </AuiIf>
  );
}

ThreadPrimitive.Suggestions establishes the suggestion scope for each item. SuggestionPrimitive.Title, .Description, and .Trigger read it. Pass send to send immediately, or omit it to place the prompt in the composer for editing. The empty thread condition dismisses the welcome grid after the first message without local state.

Follow up suggestions

import { ThreadPrimitive } from "@assistant-ui/react";
import { ThreadFollowupSuggestions } from "@/components/assistant-ui/elements/follow-up-suggestions.aui";

function ThreadFooter() {
  return (
    <ThreadPrimitive.ViewportFooter>
      <ThreadFollowupSuggestions />
      <Composer />
    </ThreadPrimitive.ViewportFooter>
  );
}

ThreadFollowupSuggestions reads s.thread.suggestions, renders one horizontally scrollable chip per follow up, and hides while the thread is empty or running. It has no props. Place it after messages and before the composer. Each chip displays title or prompt, displays the optional label, and sends the full prompt with ThreadPrimitive.Suggestion send.

When static Suggestions(...) configuration exists, ThreadPrimitive.Suggestions reads that static list instead. Use ThreadFollowupSuggestions or useAuiState((s) => s.thread.suggestions) for runtime follow ups that must coexist with static welcome prompts.

Suggestion adapters

import {
  AssistantRuntimeProvider,
  createSuggestionAdapter,
} from "@assistant-ui/react";
import { useChatRuntime } from "@assistant-ui/ai-sdk";

function RuntimeProvider({ children }: { children: React.ReactNode }) {
  const runtime = useChatRuntime({
    adapters: {
      suggestion: createSuggestionAdapter({
        async complete({ prompt, signal }) {
          const response = await fetch("/api/suggestions", {
            method: "POST",
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify({ prompt }),
            signal,
          });
          return response.json();
        },
        count: 3,
      }),
    },
  });

  return <AssistantRuntimeProvider runtime={runtime}>{children}</AssistantRuntimeProvider>;
}

createSuggestionAdapter builds the transcript prompt and invokes complete after an assistant run settles. Forward signal so a new run can cancel generation. It accepts strings or { prompt, title?, label? } records from the completion endpoint. With adapters.suggestion, the AI SDK runtime clears stale suggestions when a new run starts and replaces them with its next follow ups.

For a local runtime, pass the same adapter as adapters.suggestion to useLocalRuntime. For an external store, provide its suggestions field from application state. Those follow ups stay under application control until that state changes.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo5 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    This skill provides comprehensive documentation and React code examples for building chat interfaces using the assistant-ui library. It covers various UI primitives for threads, composers, and message rendering. No security risks or malicious patterns were identified during the analysis.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

  • Runlayer9mo

    5 files scanned · No issues

  • ZeroLeaks7mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at b0609e6. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 weeks ago.

Activeupdated 2 months ago
  • React
  • assistant-ui
  • primitives
  • radix-ui
  • unstyled-components
  • chat-ui
  • composer
  • message-rendering
  • thread

README badge

README badge for assistant-ui/skills/primitives

Builds custom assistant chat UIs from composable, unstyled @assistant-ui/react primitives (ThreadPrimitive, ComposerPrimitive, MessagePrimitive, ActionBarPrimitive, and others) following Radix UI patterns. Use when you need fine-grained control over thread rendering, message parts (text, image, reasoning, tool-call), composer behavior, and action bars, and are willing to supply your own styling via className.

Generated from the current SKILL.md.

Are these components styled by default?
No. The primitives ship unstyled and require you to add className and apply your own Tailwind, CSS, or styling system.
What do I need to wrap primitives in?
Primitives must be wrapped in AssistantRuntimeProvider, and child primitives require their parent primitive to provide context.
How do I render different message types like text, images, and tool calls?
Use MessagePrimitive.Parts with a children render function that switches on part.type (text, image, reasoning, tool-call) and returns appropriate JSX for each.
Should I use .If or AuiIf for conditional rendering?
Prefer AuiIf for new code; the .If components on primitives are deprecated but still functional.
What's the difference between MessagePrimitive.Parts and MessagePrimitive.Content?
MessagePrimitive.Parts is the canonical API; MessagePrimitive.Content is a deprecated alias for the same functionality.

Generated from the current SKILL.md. These answers refresh after source changes.