AncrelDocumentationv0.3.0

Search documentation

    Playground / fe.chat-composer

    ChatComposer playground

    Compose a controlled message with an IME-safe send shortcut and a focused Escape interrupt.

    Preview

    Example controls

    State matrix

    dark / comfortable
    VariantDefault
    Sample

    Published example

    API reference
    'use client'
    
    import { useState } from 'react'
    import { ChatComposer } from '@ancrel/workspace'
    
    export default function App() {
      const [draft, setDraft] = useState('')
      const [sending, setSending] = useState(false)
      const [message, setMessage] = useState('')
      return <>
        <ChatComposer label="Message" placeholder="Write a message" value={draft} onValueChange={setDraft}
          busy={sending} onSend={text => { setMessage(text); setDraft(''); setSending(true) }}
          onInterrupt={() => setSending(false)} leading={<span>{draft.length} characters</span>} />
        <output aria-label="Delivery">{sending ? 'Sending' : 'Idle'}</output>
        <p>{message}</p>
      </>
    }