Chat

Suggest Field

Textarea with inline completion: a ghost suggestion follows the text, Tab accepts and Esc dismisses, and a Suggest button turns into Accept beside Dismiss. The caller supplies the suggestion.

The source comes with full access.

One payment of $149 ($49 for now) opens the source right here and lets the CLI install every paid component, with lifetime updates.

Installation

pnpm dlx shadcn add @01orbital/suggest-field
npx shadcn add @01orbital/suggest-field
yarn shadcn add @01orbital/suggest-field
bunx --bun shadcn add @01orbital/suggest-field

Part of the 01orbital library. With a license, put ORBITAL_TOKEN in .env.local and the same command installs it (licensed install, pricing).

It lands at components/chat/suggest-field.tsx, as source you own and edit.

Usage

"use client"

import * as React from "react"

import { SuggestField } from "@/components/chat/suggest-field"

const GHOST = "can be swapped for any backend that streams SSE."

export default function SuggestFieldDemo() {
  const [value, setValue] = React.useState(
    "The registry ships the conversation surface as primitives, so the transport"
  )
  const [suggestion, setSuggestion] = React.useState("")
  const [loading, setLoading] = React.useState(false)
  const timer = React.useRef<number | null>(null)

  React.useEffect(
    () => () => {
      if (timer.current) window.clearTimeout(timer.current)
    },
    []
  )

  return (
    <div className="max-w-xl">
      <SuggestField
        value={value}
        onValueChange={setValue}
        onRequest={() => {
          setLoading(true)
          timer.current = window.setTimeout(() => {
            setSuggestion(GHOST)
            setLoading(false)
          }, 700)
        }}
        onDismiss={() => setSuggestion("")}
        suggestion={suggestion}
        loading={loading}
        placeholder="Start a sentence…"
      />
    </div>
  )
}

API reference

Prop

Type

Dependencies

npm: cn. The CLI installs them for you.

Registry pieces it installs with it:

  • button
  • kbd
  • textarea