Skip to Content
NarakUI

Composer

The assistant input card. Pin activity chrome, mix layout slots, and compare send/stop states.

Playground

Set each activity state with a button. Mix slots and accents on the same card. success remounts via pulseKey so the halo replays.

Activity
Accent
Slots

Activity states

working paints the rotating spectrum ring. success is a one-shot halo. disabled dims the card.

Idle

Ask a question…

Working

Write a research agent…

Success

Write a research agent…

Disabled

Write a research agent…

Slots

Surfaces the card can attach around the editor: footerStart and footerEnd, the one-row layout="compact", an attachments strip inside the card, validationMessage and disclaimer copy, a tucked bottomElement, an attached topElement (also used for queued actions), a floating topSlot, and an activeSlot takeover such as the question tool.

disclaimer has no background, so it sits cleanly on whatever surface hosts the composer.

When topElement stacks several strips, such as a usage notice and a message queue, render one ComposerAttachedWash first and keep the strips transparent. The wash paints a single surface from the top strip down past the card, so it doesn't break around the queue.

Which brand should this agent use?

The first turn is scoped to this brand.

Ask a question…

AI can make mistakes. Check important info.

Question tool

The ask-user prompt takes over the card through activeSlot. Single choice, multi choice, free text, and multi-step prompts share the same chrome. With layout="compact", pass a compact question tool to promptSlot instead, so it sits above the one-row editor.

Question
Which brand should this agent use?

Send button

idle dims send. typing enables it. streaming swaps the control for stop. Composer renders this button for you; ComposerSendButton is exported for custom footers.

Accents

Working chrome can be tinted with any design-system color token or CSS custom property.

Write a research agent that tracks competitor mentions.

Installation

pnpm dlx shadcn@latest add @narakui/composer

Add "@narakui": "https://ui.narakcode.dev/r/{name}.json" to components.json, or install directly from https://ui.narakcode.dev/r/composer.json.

Usage

import { Composer } from '@/components/ui/composer';

<Composer activityState="working" onSubmit={handleSubmit}>
  <Editor />
</Composer>

Composer is presentational. Product chats derive activityState from streaming and submit flags, then pass the result in.

Composer Properties

PropTypeDefaultDescription
activityState'idle' | 'working' | 'success' | 'disabled''idle'Visual chrome on the card. working paints the spectrum ring. success is a one-shot halo. disabled dims the card and also disables send and design-system Buttons in the footer slots.
activityAccent'blue' | 'red' | 'orange' | 'green' | 'purple' | 'gray' | string'var(--color-fill-blue)'Built-in accent preset or CSS color for the working spectrum and success pulse. Defaults to fill-blue.
pulseKeynumber0Increments so the success halo remounts and replays
sendState'idle' | 'typing' | 'streaming'—Send/stop visual role. Derived from activity and sendDisabled when omitted.
sendDisabledbooleanfalseBlocks submitting a new message. Stopping an in-flight response stays available.
onSubmit() => void—Called when the user submits from the send button
onStop() => void—Called when the user clicks stop during streaming
sendLabelstring'Send message'Tooltip and aria label for send
stopLabelstring'Stop response'Tooltip and aria label for stop
sendTextstring—Visible send text, shown in place of the arrow while not streaming
sendTextIconIconValue—Leading icon beside sendText. Takes an icon name or descriptor.
sendLoadingbooleanfalseShows a spinner on send while a submission is pending
layout'default' | 'compact''default'Compact puts the footer slots, editor, and send on one row and hides attachments
onCompactOverflow() => void—Called once per compact session when the editor grows past one line. Switch layout back to default here.
footerStartReactNode—Slot on the leading edge of the composer footer
footerEndReactNode—Slot on the trailing edge of the footer, before send/stop
disclaimerReactNode—Helper text rendered below the visible composer card
topSlotReactNode—Floating slot rendered above the card
promptSlotReactNode—Interactive clarification rendered above the editor card, such as a compact question tool
promptSlotKeystring—Identity used to remount the prompt content when it changes
topElementReactNode—Surface rendered immediately above and behind the composer card. Product queues sit here, not as an activity state.
bottomElementReactNode—Surface tucked under the floating card. Paints its own background and rounding.
activeSlotReactNode—Replaces the editor and footer when a product flow takes over the card
isSlotExitingbooleanfalseKeeps the outgoing activeSlot content mounted out of flow while the editor returns
hasInteractiveSlotbooleanfalseKeeps an interactive slot's footer in place while the card height animates
slotFooterStartReactNode—Leading control in the interactive slot's footer rail
attachmentsReactNode—Attachment strip above the editor. Stays interactive when the card is disabled.
validationMessageReactNode—Validation copy rendered beneath the card
scrollControlReactNode—Viewport control above every composer surface. Left unset, the frame reserves its height. Pass null when the surface owns spacing.
childrenReactNode—Editor surface supplied by the consumer
classNamestring—Extra classes on the outer frame
cardPropsHTMLAttributes<HTMLDivElement>—Attributes spread onto the visible card
wrapperRefRef<HTMLDivElement>—Ref to the outer frame
cardRefRef<HTMLDivElement>—Ref to the visible card
inertbooleanfalseMarks the whole frame as non-interactive

ComposerSendButton Properties

PropTypeDefaultDescription
state (Required)'idle' | 'typing' | 'streaming'—idle is dimmed, typing is enabled, streaming shows stop
disabledbooleanfalseDisables send. Ignored while streaming.
onClick() => void—Send or stop action
ariaLabelstring—Accessible name. Defaults to Send or Stop from state.
textstring—Visible send text. Turns the circle into a labeled pill. Stop stays circular.
textIconIconValue—Leading icon beside text. Ignored without text or while streaming.
loadingbooleanfalseShows a spinner and disables send. Ignored while streaming.
classNamestring—Extra classes on the button