{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "prompt-bar",
  "type": "registry:component",
  "title": "Prompt Bar",
  "description": "A chat composer with an auto-growing textarea, attach and mic buttons, a model picker and a send button. Enter sends, Shift+Enter adds a line.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "agent-kit",
    "composer",
    "input",
    "chat",
    "textarea",
    "model picker",
    "agent"
  ],
  "docs": "https://hyperblur.dev/effects/prompt-bar",
  "files": [
    {
      "path": "registry/hyperblur/prompt-bar.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/prompt-bar.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface PromptBarProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\" | \"onSubmit\"> {\n  models?: string[];\n  defaultModel?: string;\n  maxRows?: number;\n  placeholder?: string;\n  disabled?: boolean;\n  color?: string;\n  attachIcon?: React.ReactNode;\n  micIcon?: React.ReactNode;\n  onAttach?: () => void;\n  onMic?: () => void;\n  onSend?: (text: string, model: string) => void;\n}\n\nconst css = `\n.hb-prb {\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  padding: 10px 10px 8px 14px;\n  border: 1px solid #262626;\n  border-radius: 16px;\n  color: #ededed;\n  font-family: var(--font-sans), ui-sans-serif, system-ui, sans-serif;\n  font-size: 13px;\n  background: #141414;\n  transition: border-color .2s ease, box-shadow .2s ease;\n}\n.hb-prb:focus-within {\n  border-color: color-mix(in srgb, var(--hb-prb-color, #2f7bff) 70%, #262626);\n  box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-prb-color, #2f7bff) 16%, transparent);\n}\n.hb-prb[data-disabled=\"true\"] { opacity: .55; }\n.hb-prb-input {\n  display: block;\n  box-sizing: border-box;\n  width: 100%;\n  margin: 0;\n  padding: 0;\n  border: 0;\n  outline: 0;\n  resize: none;\n  overflow-y: auto;\n  color: #ededed;\n  font: inherit;\n  line-height: 20px;\n  background: transparent;\n  scrollbar-width: thin;\n  scrollbar-color: #2e2e2e transparent;\n}\n.hb-prb-input::placeholder { color: #6f6f6f; }\n.hb-prb-bar { display: flex; align-items: center; gap: 4px; margin-top: 8px; }\n.hb-prb-spacer { flex: 1 1 auto; }\n.hb-prb-icon {\n  display: grid;\n  flex: 0 0 auto;\n  place-items: center;\n  width: 28px;\n  height: 28px;\n  margin: 0;\n  padding: 0;\n  border: 0;\n  border-radius: 8px;\n  color: #8f8f8f;\n  cursor: pointer;\n  background: transparent;\n  transition: color .15s ease, background .15s ease;\n}\n.hb-prb-icon:hover:not(:disabled) { color: #ededed; background: #1f1f1f; }\n.hb-prb-icon:disabled { cursor: not-allowed; }\n.hb-prb-icon:focus-visible, .hb-prb-chip:focus-visible, .hb-prb-send:focus-visible {\n  outline: 2px solid var(--hb-prb-color, #2f7bff);\n  outline-offset: 1px;\n}\n.hb-prb-icon svg { width: 16px; height: 16px; }\n.hb-prb-model { position: relative; }\n.hb-prb-chip {\n  display: inline-flex;\n  align-items: center;\n  gap: 5px;\n  height: 26px;\n  margin: 0;\n  padding: 0 8px 0 10px;\n  border: 1px solid #262626;\n  border-radius: 999px;\n  color: #c4c4c4;\n  font-family: var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace;\n  font-size: 11.5px;\n  cursor: pointer;\n  background: #171717;\n  transition: border-color .15s ease, color .15s ease;\n}\n.hb-prb-chip:hover:not(:disabled) { color: #ededed; border-color: #333333; }\n.hb-prb-chip:disabled { cursor: not-allowed; }\n.hb-prb-chip svg { width: 10px; height: 10px; transition: transform .2s ease; }\n.hb-prb-chip[aria-expanded=\"true\"] svg { transform: rotate(180deg); }\n.hb-prb-menu {\n  position: absolute;\n  bottom: calc(100% + 6px);\n  left: 0;\n  z-index: 5;\n  min-width: 150px;\n  margin: 0;\n  padding: 4px;\n  list-style: none;\n  border: 1px solid #262626;\n  border-radius: 12px;\n  background: #171717;\n  box-shadow: 0 12px 32px rgba(0,0,0,.5);\n  animation: hb-prb-pop .15s ease both;\n}\n@keyframes hb-prb-pop {\n  from { opacity: 0; transform: translateY(4px); }\n  to { opacity: 1; transform: none; }\n}\n.hb-prb-option {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 10px;\n  padding: 6px 8px;\n  border-radius: 8px;\n  color: #c4c4c4;\n  font-family: var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace;\n  font-size: 11.5px;\n  cursor: pointer;\n  outline: 0;\n}\n.hb-prb-option:hover, .hb-prb-option:focus-visible { color: #ededed; background: #232323; }\n.hb-prb-option[aria-selected=\"true\"] { color: #ededed; }\n.hb-prb-option svg { width: 11px; height: 11px; color: var(--hb-prb-color, #2f7bff); }\n.hb-prb-send {\n  display: grid;\n  flex: 0 0 auto;\n  place-items: center;\n  width: 28px;\n  height: 28px;\n  margin: 0 0 0 2px;\n  padding: 0;\n  border: 0;\n  border-radius: 50%;\n  color: #8f8f8f;\n  cursor: not-allowed;\n  background: #1f1f1f;\n  transition: background .2s ease, color .2s ease, transform .15s ease;\n}\n.hb-prb-send:not(:disabled) { color: #ffffff; cursor: pointer; background: var(--hb-prb-color, #2f7bff); }\n.hb-prb-send:not(:disabled):active { transform: scale(.92); }\n.hb-prb-send svg { width: 14px; height: 14px; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-prb, .hb-prb-icon, .hb-prb-chip, .hb-prb-chip svg, .hb-prb-send { transition: none; }\n  .hb-prb-menu { animation: none; }\n}\n`;\n\nconst LINE = 20;\n\nexport function PromptBar({\n  models = [\"default\"],\n  defaultModel,\n  maxRows = 6,\n  placeholder = \"Send a message\",\n  disabled = false,\n  color = \"#2f7bff\",\n  attachIcon,\n  micIcon,\n  onAttach,\n  onMic,\n  onSend,\n  className = \"\",\n  style,\n  ...rest\n}: PromptBarProps) {\n  const uid = React.useId();\n  const [value, setValue] = React.useState(\"\");\n  const [picked, setPicked] = React.useState(defaultModel ?? models[0] ?? \"\");\n  const [open, setOpen] = React.useState(false);\n  const area = React.useRef<HTMLTextAreaElement>(null);\n  const root = React.useRef<HTMLDivElement>(null);\n  const chip = React.useRef<HTMLButtonElement>(null);\n  const menu = React.useRef<HTMLUListElement>(null);\n\n  const model = models.includes(picked) ? picked : (models[0] ?? \"\");\n  const canSend = !disabled && value.trim().length > 0;\n\n  React.useLayoutEffect(() => {\n    const el = area.current;\n    if (!el) return;\n    el.style.height = \"auto\";\n    el.style.height = `${Math.min(el.scrollHeight, Math.max(1, maxRows) * LINE)}px`;\n  }, [value, maxRows]);\n\n  React.useEffect(() => {\n    if (!open) return;\n    const selected = menu.current?.querySelector<HTMLElement>('[aria-selected=\"true\"]');\n    (selected ?? menu.current?.querySelector<HTMLElement>(\"li\"))?.focus();\n    const onDown = (e: PointerEvent) => {\n      if (root.current && !root.current.contains(e.target as Node)) setOpen(false);\n    };\n    document.addEventListener(\"pointerdown\", onDown);\n    return () => document.removeEventListener(\"pointerdown\", onDown);\n  }, [open]);\n\n  function send() {\n    const text = value.trim();\n    if (!text || disabled) return;\n    onSend?.(text, model);\n    setValue(\"\");\n  }\n\n  function onKeyDown(e: React.KeyboardEvent<HTMLTextAreaElement>) {\n    if (e.key === \"Enter\" && !e.shiftKey && !e.nativeEvent.isComposing) {\n      e.preventDefault();\n      send();\n    }\n  }\n\n  function choose(next: string) {\n    setPicked(next);\n    setOpen(false);\n    chip.current?.focus();\n  }\n\n  function onMenuKeyDown(e: React.KeyboardEvent<HTMLUListElement>) {\n    const items = Array.from(e.currentTarget.querySelectorAll<HTMLElement>(\"li\"));\n    const at = items.indexOf(document.activeElement as HTMLElement);\n    if (e.key === \"ArrowDown\") {\n      e.preventDefault();\n      items[(at + 1) % items.length]?.focus();\n    } else if (e.key === \"ArrowUp\") {\n      e.preventDefault();\n      items[(at - 1 + items.length) % items.length]?.focus();\n    } else if (e.key === \"Home\") {\n      e.preventDefault();\n      items[0]?.focus();\n    } else if (e.key === \"End\") {\n      e.preventDefault();\n      items[items.length - 1]?.focus();\n    } else if (e.key === \"Escape\") {\n      e.preventDefault();\n      setOpen(false);\n      chip.current?.focus();\n    } else if (e.key === \"Tab\") {\n      setOpen(false);\n    }\n  }\n\n  return (\n    <div\n      ref={root}\n      className={`hb-prb ${className}`}\n      style={{ \"--hb-prb-color\": color, ...style } as React.CSSProperties}\n      data-disabled={disabled}\n      {...rest}\n    >\n      <style href=\"hb-prompt-bar\" precedence=\"default\">{css}</style>\n      <textarea\n        ref={area}\n        className=\"hb-prb-input\"\n        rows={1}\n        value={value}\n        placeholder={placeholder}\n        aria-label={placeholder}\n        disabled={disabled}\n        onChange={(e) => setValue(e.target.value)}\n        onKeyDown={onKeyDown}\n      />\n      <div className=\"hb-prb-bar\">\n        <button className=\"hb-prb-icon\" type=\"button\" aria-label=\"Attach file\" disabled={disabled} onClick={onAttach}>\n          {attachIcon ?? (\n            <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              <path d=\"M13.2 7.6l-5 5a3.2 3.2 0 0 1-4.5-4.5l5.2-5.2a2.1 2.1 0 0 1 3 3L6.6 10.9a1 1 0 0 1-1.5-1.5l4.7-4.7\" />\n            </svg>\n          )}\n        </button>\n        <button className=\"hb-prb-icon\" type=\"button\" aria-label=\"Use microphone\" disabled={disabled} onClick={onMic}>\n          {micIcon ?? (\n            <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              <rect x=\"5.8\" y=\"1.8\" width=\"4.4\" height=\"7.4\" rx=\"2.2\" />\n              <path d=\"M3.4 7.6a4.6 4.6 0 0 0 9.2 0M8 12.2v2\" />\n            </svg>\n          )}\n        </button>\n        <span className=\"hb-prb-spacer\" />\n        <div className=\"hb-prb-model\">\n          <button\n            ref={chip}\n            className=\"hb-prb-chip\"\n            type=\"button\"\n            aria-haspopup=\"listbox\"\n            aria-expanded={open}\n            aria-controls={`${uid}-models`}\n            aria-label={`Model: ${model}`}\n            disabled={disabled}\n            onClick={() => setOpen((v) => !v)}\n          >\n            {model}\n            <svg viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              <path d=\"M2.5 4.5L6 8l3.5-3.5\" />\n            </svg>\n          </button>\n          {open ? (\n            <ul\n              ref={menu}\n              id={`${uid}-models`}\n              className=\"hb-prb-menu\"\n              role=\"listbox\"\n              aria-label=\"Model\"\n              onKeyDown={onMenuKeyDown}\n            >\n              {models.map((m) => (\n                <li\n                  key={m}\n                  className=\"hb-prb-option\"\n                  role=\"option\"\n                  tabIndex={-1}\n                  aria-selected={m === model}\n                  onClick={() => choose(m)}\n                  onKeyDown={(e) => {\n                    if (e.key === \"Enter\" || e.key === \" \") {\n                      e.preventDefault();\n                      choose(m);\n                    }\n                  }}\n                >\n                  {m}\n                  {m === model ? (\n                    <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                      <path d=\"M3 8.5l3.2 3.2L13 4.8\" />\n                    </svg>\n                  ) : null}\n                </li>\n              ))}\n            </ul>\n          ) : null}\n        </div>\n        <button className=\"hb-prb-send\" type=\"button\" aria-label=\"Send message\" disabled={!canSend} onClick={send}>\n          <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n            <path d=\"M8 13V3M3.5 7.5L8 3l4.5 4.5\" />\n          </svg>\n        </button>\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}