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.

referencesaction-bar.md

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

ActionBarPrimitive

Message actions: copy, reload, edit, feedback, speech, export. Handles auto hide on hover, automatic disabling per action, and floating behavior. Root renders a <div>; every action renders a <button>. Must render inside MessagePrimitive.Root, which it reads message state from.

Parts

Part Notes
.Root hideWhenRunning, autohide ("never" default, "not-last", "always"), autohideFloat ("never" default, "always", "single-branch").
.Copy Disabled with no copyable text, or while an assistant message is still running. copiedDuration (default 3000ms) controls how long data-copied stays set.
.Reload Disabled while the thread is running or disabled, or the message is not from the assistant. Creates a new branch.
.Edit Disabled while already editing. Calls aui.composer.beginEdit().
.Speak / .StopSpeaking Disabled with no speakable text, or while running. Requires a SpeechSynthesisAdapter.
.FeedbackPositive / .FeedbackNegative data-submitted once s.message.metadata.submittedFeedback matches. Requires a feedback adapter.
.ExportMarkdown Downloads Markdown, or calls a custom onExport handler.

Auto hide and floating

<ActionBarPrimitive.Root
  hideWhenRunning
  autohide="not-last"
  autohideFloat="always"
  className="data-[floating]:opacity-0 data-[floating]:group-hover:opacity-100 data-[floating]:transition-opacity"
>
  <ActionBarPrimitive.Copy>Copy</ActionBarPrimitive.Copy>
  <ActionBarPrimitive.Reload>Regenerate</ActionBarPrimitive.Reload>
</ActionBarPrimitive.Root>

autohide="not-last" hides the bar on every message except the last, revealed on hover (the hover state MessagePrimitive.Root tracks automatically); "always" hides on every message. When autohideFloat is set, a hidden bar keeps rendering with a data-floating attribute instead of leaving the DOM, so you can animate it in with CSS rather than mounting on hover. "single-branch" only floats when the message has exactly one branch.

Copy and feedback state

<ActionBarPrimitive.Copy copiedDuration={2000} className="group">
  <CopyIcon className="group-data-[copied]:hidden" />
  <CheckIcon className="hidden group-data-[copied]:block" />
</ActionBarPrimitive.Copy>

<ActionBarPrimitive.FeedbackPositive className="data-[submitted]:text-green-500">👍</ActionBarPrimitive.FeedbackPositive>
<ActionBarPrimitive.FeedbackNegative className="data-[submitted]:text-red-500">👎</ActionBarPrimitive.FeedbackNegative>

FeedbackPositive and FeedbackNegative are mutually exclusive (submitting one replaces the other in s.message.metadata.submittedFeedback), but there is no built in path back to "no feedback": aui.message.submitFeedback({ type }) only ever writes a reaction.

ActionBarMorePrimitive: the overflow menu

A Radix DropdownMenu scoped to the action bar's interaction lock, for grouping secondary actions behind a "more" button.

Part Renders Notes
.Root provider only Radix DropdownMenu.Root.
.Trigger <button> Opens the menu.
.Content <div> (portal) Defaults sideOffset={4}.
.Item <div> Maps to DropdownMenu.Item; prefer asChild to compose an ActionBarPrimitive button into it.
.Separator <div> Visual divider.
import { ActionBarMorePrimitive, ActionBarPrimitive } from "@assistant-ui/react";
import { MoreHorizontalIcon } from "lucide-react";

<ActionBarPrimitive.Root>
  <ActionBarPrimitive.Copy>Copy</ActionBarPrimitive.Copy>
  <ActionBarPrimitive.Reload>Regenerate</ActionBarPrimitive.Reload>
  <ActionBarMorePrimitive.Root>
    <ActionBarMorePrimitive.Trigger className="flex size-8 items-center justify-center rounded-lg hover:bg-muted">
      <MoreHorizontalIcon className="size-4" />
    </ActionBarMorePrimitive.Trigger>
    <ActionBarMorePrimitive.Content side="bottom" align="end">
      <ActionBarMorePrimitive.Item asChild>
        <ActionBarPrimitive.ExportMarkdown>Export Markdown</ActionBarPrimitive.ExportMarkdown>
      </ActionBarMorePrimitive.Item>
      <ActionBarMorePrimitive.Separator />
      <ActionBarMorePrimitive.Item asChild>
        <ActionBarPrimitive.FeedbackPositive>Helpful</ActionBarPrimitive.FeedbackPositive>
      </ActionBarMorePrimitive.Item>
    </ActionBarMorePrimitive.Content>
  </ActionBarMorePrimitive.Root>
</ActionBarPrimitive.Root>

Feedback adapter

const runtime = useChatRuntime({
  adapters: {
    feedback: {
      submit: async ({ messageId, type }) => {
        await fetch("/api/feedback", { method: "POST", body: JSON.stringify({ messageId, type }) });
      },
    },
  },
});

Patterns

// Assistant action bar
<ActionBarPrimitive.Root hideWhenRunning autohide="not-last" autohideFloat="single-branch">
  <ActionBarPrimitive.Copy>Copy</ActionBarPrimitive.Copy>
  <ActionBarPrimitive.Reload>Regenerate</ActionBarPrimitive.Reload>
  <ActionBarPrimitive.ExportMarkdown>Export</ActionBarPrimitive.ExportMarkdown>
</ActionBarPrimitive.Root>

// User action bar
<ActionBarPrimitive.Root hideWhenRunning autohide="not-last">
  <ActionBarPrimitive.Edit>Edit</ActionBarPrimitive.Edit>
</ActionBarPrimitive.Root>

// Speech toggle
<AuiIf condition={(s) => s.message.speech == null}>
  <ActionBarPrimitive.Speak>Play</ActionBarPrimitive.Speak>
</AuiIf>
<AuiIf condition={(s) => s.message.speech != null}>
  <ActionBarPrimitive.StopSpeaking>Stop</ActionBarPrimitive.StopSpeaking>
</AuiIf>

Common Gotchas

"must be used within MessagePrimitive" error

  • ActionBarPrimitive reads message state from the nearest MessagePrimitive.Root. Render it inside your message component.

Feedback buttons do nothing

  • They require a feedback adapter on the runtime (adapters.feedback.submit). With none configured, submitFeedback has nowhere to send.

Copy button never shows the checkmark

  • Toggle icons off data-copied (via className or AuiIf on s.message.isCopied), not local component state; the attribute already tracks copiedDuration for you.

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.