Skip to content
Sign upPro
ComposerTemplate composerMenu

Template composer (Pro)

ProIncluded in $99

Prompt templates with fillable slots inline in the sentence. Tab between them, watch filled ones settle into the text, and never send half a prompt.

ProA coffee roaster's support desk fills a double charge reply slot by slot. Filled slots settle into the sentence, then it sends.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/template-composer

Needs chatcn Pro

This command works with a Pro license, along with every Pro component.

Or start free: sign up and get three Pro components on us, with a new one every month.

Usage

tsx
import { TemplateComposer } from "@/components/ui/chatcn/pro/template-composer"

<TemplateComposer
  templates={[
    {
      id: "refund",
      name: "Double charge reply",
      template: "Write a {{tone:warm}} reply to {{customer}} about order {{order_number}}.",
    },
  ]}
  onSubmit={({ text, template, values }) => send(text)}
/>

Templates use the same {{name}} and {{name:default}} syntax as the free prompt template, so one library of prompts serves both. Picking a template (the Templates button, or / in the empty composer) lays the sentence out with each slot as an inline chip named for what goes there. Slots are text, not inputs: long values wrap with the sentence, and a filled slot drops its chip and keeps only a dotted rule, so the finished prompt reads like something you wrote. Send with required slots empty does not send: it jumps to the first blank, marks the rest and names them under the composer. Edit as text turns the template into a plain draft, with blanks kept as [Label] so nothing silently disappears. With no template it is the free PromptInput, with the same Enter, paste and IME behaviour.

Examples

States

ProFree text, a fresh template, half filled, Send blocked by blanks, ready, streaming, long values and disabled.

Props

PropTypeNotes
templatesComposerTemplate[]{ id, name, description?, template, slots? }
template, defaultTemplate, onTemplateChangestring | nullThe active template, or null for free text
values, defaultValues, onValuesChangeRecord<string, string>What is typed in each slot
onSubmit({ text, template?, values? }) => voidOnly once every required slot is filled
slots[name]{ label?, optional?, multiline? }Per slot details. A slot with a default is optional
slashOpensboolean/ in the empty composer opens the templates. Default true
showMissingbooleanShow the blocked send hint now
value, defaultValue, onValueChangestringThe draft, controlled or not
status, onStop"idle" | "submitting" | "streaming", () => voidSend becomes Stop in the same footprint
disabledboolean
tools, actions, attachmentsReactNodeToolbar start, before Send, above the text
labelsPartial<TemplateComposerLabels>Every string, for translation

Keyboard

KeyAction
/Open the templates from the empty composer
Tab, Shift TabNext and previous slot. Past the last slot, Tab moves on as usual
Right, Left at a slot's edgeCross into the neighbouring slot
Backspace in an empty slotBack to the previous slot
EnterSend, or jump to the first blank if any are left
EscapeStop a streaming reply

Accessibility

  • Each slot is a textbox named by its label, with aria-required and aria-invalid after a blocked send.
  • The sentence is a group labelled by the template's name, so the slots are heard in context.
  • The blocked send hint is announced politely and carries an icon, not color alone.
  • Repeated slots mirror the first and stay out of the tab order, so each blank is visited once.

Motion

Focus moves are instant because they come from the keyboard. A filled slot settles over 200 ms on the kit's ease out: the chip's fill fades and the words take the sentence's ink. Nothing moves or resizes.