{
  "schemaVersion": 1,
  "target": "react",
  "name": "input-group",
  "version": "0.1.0",
  "category": "forms",
  "title": "Input Group",
  "description": "A text field with icons, fixed text, small buttons, and key hints inside its border, labeled like Input.",
  "tags": [
    "form",
    "input",
    "addon",
    "prefix",
    "suffix",
    "base-ui"
  ],
  "requires": {
    "projectTypes": [
      "next",
      "vite-react"
    ],
    "styling": "tailwind-v4"
  },
  "npmDependencies": {
    "@base-ui/react": "^1.9.0"
  },
  "registryDependencies": [],
  "docsPath": "/components/input-group",
  "props": [
    {
      "name": "label / description / error",
      "type": "ReactNode",
      "description": "InputGroup: a bound label, helper text, and an error that marks the field invalid."
    },
    {
      "name": "busy",
      "type": "boolean",
      "default": "false",
      "description": "InputGroup: a spinner at the end and aria-busy."
    },
    {
      "name": "align",
      "type": "\"start\" | \"end\"",
      "default": "\"start\"",
      "description": "InputGroupAddon: which side the addon sits on; place it before or after the input to match."
    },
    {
      "name": "bordered",
      "type": "boolean",
      "default": "false",
      "description": "InputGroupAddon: a hairline between the addon and the input."
    },
    {
      "name": "variant",
      "type": "\"ghost\" | \"secondary\"",
      "default": "\"ghost\"",
      "description": "InputGroupButton: visual style."
    },
    {
      "name": "iconOnly",
      "type": "boolean",
      "default": "false",
      "description": "InputGroupButton: a square 28px button; give it an aria-label."
    }
  ],
  "accessibility": [
    "The label is a native <label> bound to InputGroupInput; helper and error text are linked with aria-describedby.",
    "Errors set aria-invalid on the input and turn the border red.",
    "Clicking empty space in an addon focuses the input, so the whole field is a click target.",
    "Buttons inside are real buttons with their own focus ring; the field ring only shows while the input has focus.",
    "The busy spinner is decorative and stops rotating under reduced motion; the field sets aria-busy."
  ],
  "states": [
    "default",
    "focus",
    "invalid",
    "busy",
    "disabled"
  ],
  "files": [
    {
      "path": "ui/input-group.tsx",
      "content": "\"use client\";\n\nimport { Input as BaseInput } from \"@base-ui/react/input\";\nimport { type ComponentProps, createContext, type MouseEvent, type ReactNode, useContext, useId } from \"react\";\n\ntype ClassName<State> = string | ((state: State) => string | undefined) | undefined;\n\nfunction cx(...classes: (string | false | null | undefined)[]) {\n  return classes.filter(Boolean).join(\" \");\n}\n\n/** Prepends base classes while keeping Base UI's state-function form of className working. */\nfunction withBase<State>(base: string, className: ClassName<State>) {\n  return typeof className === \"function\" ? (state: State) => cx(base, className(state)) : cx(base, className);\n}\n\ninterface GroupContextValue {\n  inputId: string;\n  messageId?: string;\n  invalid: boolean;\n}\n\nconst GroupContext = createContext<GroupContextValue | null>(null);\n\nexport interface InputGroupProps extends ComponentProps<\"div\"> {\n  /** Visible label, bound to the InputGroupInput inside. */\n  label?: ReactNode;\n  /** Helper text below the field. */\n  description?: ReactNode;\n  /** Error message. Marks the field invalid and replaces the description. */\n  error?: ReactNode;\n  /** Shows a spinner at the end of the field, for example while a value is being checked. */\n  busy?: boolean;\n  /** Classes for the wrapping element. `className` styles the bordered field. */\n  containerClassName?: string;\n}\n\n/**\n * A text field with addons inside its border: icons, fixed text such as a protocol or a domain,\n * small buttons, and key hints. It looks and labels like Input. Put exactly one InputGroupInput\n * inside, with InputGroupAddon before or after it.\n */\nexport function InputGroup({\n  label,\n  description,\n  error,\n  busy = false,\n  className,\n  containerClassName,\n  children,\n  ...props\n}: InputGroupProps) {\n  const inputId = useId();\n  const messageId = `${inputId}-message`;\n  const invalid = error != null && error !== false;\n  const message = invalid ? error : description;\n\n  return (\n    <GroupContext.Provider value={{ inputId, messageId: message ? messageId : undefined, invalid }}>\n      <div className={cx(\"grid gap-1.5\", containerClassName)}>\n        {label ? (\n          <label htmlFor={inputId} className=\"text-sm leading-5 font-medium text-zinc-950 dark:text-white\">\n            {label}\n          </label>\n        ) : null}\n        <div\n          data-invalid={invalid || undefined}\n          aria-busy={busy || undefined}\n          className={cx(\n            \"flex h-9 w-full min-w-0 items-stretch rounded-lg border bg-white text-sm text-zinc-900 shadow-sm\",\n            \"transition-[border-color,box-shadow] duration-150 ease-out motion-reduce:transition-none\",\n            \"dark:bg-zinc-950 dark:text-zinc-100\",\n            invalid\n              ? \"border-red-400 has-[input:focus]:border-red-500 has-[input:focus]:ring-3 has-[input:focus]:ring-red-500/20 dark:border-red-500/60\"\n              : \"border-zinc-300 has-[input:focus]:border-sky-500 has-[input:focus]:ring-3 has-[input:focus]:ring-sky-500/20 dark:border-zinc-700\",\n            \"has-[input:disabled]:cursor-not-allowed has-[input:disabled]:bg-zinc-50 has-[input:disabled]:opacity-60 dark:has-[input:disabled]:bg-zinc-900\",\n            className,\n          )}\n          {...props}\n        >\n          {children}\n          {busy ? (\n            <span aria-hidden=\"true\" className=\"flex items-center pr-3\">\n              <svg viewBox=\"0 0 16 16\" fill=\"none\" className=\"size-4 text-zinc-400 motion-safe:animate-spin dark:text-zinc-500\">\n                <circle cx=\"8\" cy=\"8\" r=\"6\" stroke=\"currentColor\" strokeOpacity=\"0.3\" strokeWidth=\"1.5\" />\n                <path d=\"M14 8a6 6 0 0 0-6-6\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n              </svg>\n            </span>\n          ) : null}\n        </div>\n        {message ? (\n          <p id={messageId} className={invalid ? \"text-sm text-red-600 dark:text-red-400\" : \"text-sm text-zinc-500 dark:text-zinc-400\"}>\n            {message}\n          </p>\n        ) : null}\n      </div>\n    </GroupContext.Provider>\n  );\n}\n\n/**\n * The text input inside an InputGroup. It takes the group's label, description, and error\n * automatically, and inside a Field it registers with the field instead.\n */\nexport function InputGroupInput({ id, className, \"aria-describedby\": describedBy, ...props }: BaseInput.Props) {\n  const group = useContext(GroupContext);\n  return (\n    <BaseInput\n      id={id ?? group?.inputId}\n      aria-invalid={group?.invalid || undefined}\n      aria-describedby={cx(group?.messageId, describedBy) || undefined}\n      className={withBase(\n        cx(\n          \"h-full w-full min-w-0 flex-1 bg-transparent px-3 text-sm outline-none placeholder:text-zinc-400 dark:placeholder:text-zinc-500\",\n          \"disabled:cursor-not-allowed\",\n          // Tighten the padding next to an addon so the text sits close to its icon or prefix.\n          \"[[data-align=start]+&]:pl-2 [[data-align=start][data-bordered]+&]:pl-3 has-[+[data-align=end]]:pr-2\",\n        ),\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nexport interface InputGroupAddonProps extends ComponentProps<\"div\"> {\n  /** Which side of the input the addon sits on. Place it before or after the input to match. */\n  align?: \"start\" | \"end\";\n  /** Draws a hairline between the addon and the input, for fixed text such as `https://`. */\n  bordered?: boolean;\n}\n\n/**\n * An icon, fixed text, button, or key hint at one end of the field. Render a `start` addon\n * before the input and an `end` addon after it. Clicking empty space in it focuses the input.\n */\nexport function InputGroupAddon({ align = \"start\", bordered = false, className, onMouseDown, ...props }: InputGroupAddonProps) {\n  const group = useContext(GroupContext);\n\n  function handleMouseDown(event: MouseEvent<HTMLDivElement>) {\n    onMouseDown?.(event);\n    if (event.defaultPrevented || (event.target as HTMLElement).closest(\"button, a, input, select, textarea\")) return;\n    const input = group ? document.getElementById(group.inputId) : null;\n    if (input) {\n      event.preventDefault();\n      input.focus();\n    }\n  }\n\n  return (\n    <div\n      data-align={align}\n      data-bordered={bordered || undefined}\n      onMouseDown={handleMouseDown}\n      className={cx(\n        \"flex shrink-0 cursor-text items-center gap-1.5 text-sm whitespace-nowrap text-zinc-500 select-none dark:text-zinc-500\",\n        \"[&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-zinc-400 dark:[&_svg]:text-zinc-500\",\n        align === \"start\" ? \"pl-3\" : \"has-[button]:pr-1 not-has-[button]:pr-3\",\n        bordered && (align === \"start\" ? \"border-r border-zinc-950/[0.07] pr-3 dark:border-white/[0.08]\" : \"border-l border-zinc-950/[0.07] pl-3 dark:border-white/[0.08]\"),\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nconst buttonVariants = {\n  ghost: \"text-zinc-600 hover:bg-zinc-950/[0.05] hover:text-zinc-950 dark:text-zinc-400 dark:hover:bg-white/[0.08] dark:hover:text-white\",\n  secondary: cx(\n    \"border border-zinc-950/12 bg-white text-zinc-950 hover:border-zinc-950/20 hover:bg-zinc-950/[0.03]\",\n    \"dark:border-white/15 dark:bg-black dark:text-white dark:hover:border-white/25 dark:hover:bg-white/[0.06]\",\n  ),\n} as const;\n\nexport interface InputGroupButtonProps extends ComponentProps<\"button\"> {\n  variant?: keyof typeof buttonVariants;\n  /** A square 28px button for a single icon. Give it an `aria-label`. */\n  iconOnly?: boolean;\n}\n\n/** A compact button inside an end addon, such as Copy, Reveal, or Search. */\nexport function InputGroupButton({ variant = \"ghost\", iconOnly = false, type = \"button\", className, ...props }: InputGroupButtonProps) {\n  return (\n    <button\n      type={type}\n      className={cx(\n        \"inline-flex h-7 cursor-pointer items-center justify-center gap-1.5 rounded-md text-xs font-medium whitespace-nowrap select-none\",\n        iconOnly ? \"w-7\" : \"px-2\",\n        buttonVariants[variant],\n        \"transition-[background-color,border-color,color,scale] duration-150 ease-out active:duration-100 motion-safe:active:scale-[0.97] motion-reduce:transition-none\",\n        \"focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-sky-500\",\n        \"disabled:pointer-events-none disabled:opacity-45 [&_svg]:size-3.5 [&_svg]:text-current\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\n/** A keyboard shortcut hint, for example `⌘K` at the end of a search field. */\nexport function InputGroupKbd({ className, ...props }: ComponentProps<\"kbd\">) {\n  return (\n    <kbd\n      className={cx(\n        \"inline-flex h-5 min-w-5 items-center justify-center rounded-[5px] border px-1 font-mono text-[11px] leading-none font-medium text-zinc-500\",\n        \"border-zinc-950/10 shadow-[0_1px_0_rgb(0_0_0/0.04)] dark:border-white/15 dark:text-zinc-400 dark:shadow-none\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n"
    }
  ],
  "example": {
    "content": "\"use client\";\n\nimport { useState } from \"react\";\nimport { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupKbd } from \"@/components/shaken/ui/input-group\";\n\nfunction SearchIcon() {\n  return (\n    <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\">\n      <circle cx=\"7\" cy=\"7\" r=\"4.25\" />\n      <path d=\"M10.25 10.25L13.5 13.5\" />\n    </svg>\n  );\n}\n\nfunction CopyIcon() {\n  return (\n    <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinejoin=\"round\">\n      <rect x=\"5.25\" y=\"5.25\" width=\"8\" height=\"8\" rx=\"1.5\" />\n      <path d=\"M10.75 5.25V4.25a1.5 1.5 0 0 0-1.5-1.5h-5a1.5 1.5 0 0 0-1.5 1.5v5a1.5 1.5 0 0 0 1.5 1.5h1\" />\n    </svg>\n  );\n}\n\nfunction CheckIcon() {\n  return (\n    <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n      <path d=\"M3.75 8.25l2.75 2.75 5.75-6\" />\n    </svg>\n  );\n}\n\nexport default function InputGroupExample() {\n  const [copied, setCopied] = useState(false);\n  const webhook = \"https://hooks.northwind.dev/runs/7f3a9c\";\n\n  function copy() {\n    void navigator.clipboard?.writeText(webhook);\n    setCopied(true);\n    window.setTimeout(() => setCopied(false), 1600);\n  }\n\n  return (\n    <div className=\"grid w-full max-w-sm gap-5\">\n      <InputGroup>\n        <InputGroupAddon>\n          <SearchIcon />\n        </InputGroupAddon>\n        <InputGroupInput aria-label=\"Search runs\" placeholder=\"Search runs, tools, and traces\" />\n        <InputGroupAddon align=\"end\">\n          <InputGroupKbd>⌘K</InputGroupKbd>\n        </InputGroupAddon>\n      </InputGroup>\n\n      <InputGroup label=\"Workspace URL\" description=\"Lowercase letters, numbers, and dashes.\">\n        <InputGroupAddon bordered>https://</InputGroupAddon>\n        <InputGroupInput defaultValue=\"northwind\" spellCheck={false} />\n        <InputGroupAddon align=\"end\">.shaken.dev</InputGroupAddon>\n      </InputGroup>\n\n      <InputGroup label=\"Webhook URL\">\n        <InputGroupInput readOnly value={webhook} className=\"font-mono text-xs\" />\n        <InputGroupAddon align=\"end\">\n          <InputGroupButton onClick={copy}>\n            {copied ? <CheckIcon /> : <CopyIcon />}\n            {copied ? \"Copied\" : \"Copy\"}\n          </InputGroupButton>\n        </InputGroupAddon>\n      </InputGroup>\n\n      <InputGroup label=\"Monthly spend limit\" error=\"Set a limit of at least $10.\">\n        <InputGroupAddon>$</InputGroupAddon>\n        <InputGroupInput inputMode=\"decimal\" defaultValue=\"5\" className=\"tabular-nums\" />\n        <InputGroupAddon align=\"end\">USD</InputGroupAddon>\n      </InputGroup>\n\n      <InputGroup label=\"Slug\" description=\"Checking availability…\" busy>\n        <InputGroupInput defaultValue=\"release-notes-writer\" spellCheck={false} />\n      </InputGroup>\n    </div>\n  );\n}\n"
  }
}
