{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tw-icon-button",
  "type": "registry:ui",
  "title": "react-tw/icon-button.tsx",
  "description": "Carbon `IconButton` as a React + Tailwind component, as `<ui-icon-button>`: a square icon-only Copied from @purpurabog/ui 2.3.0; the package is the maintained source, this copy is yours to change. Icons from the Carbon Design System (Apache-2.0, © IBM Corp.; see THIRD-PARTY-NOTICES.md in the package).",
  "dependencies": [],
  "registryDependencies": [
    "@kanok-ui/core-badge-indicator",
    "@kanok-ui/core-position",
    "@kanok-ui/tw-badge-indicator",
    "@kanok-ui/tw-button",
    "@kanok-ui/tw-theme",
    "@kanok-ui/tw-tooltip",
    "@kanok-ui/tw-utils"
  ],
  "files": [
    {
      "path": "src/react-tw/icon-button.tsx",
      "type": "registry:ui",
      "target": "components/ui/react-tw/icon-button.tsx",
      "content": "import { useId, type ReactNode } from 'react';\nimport type { Placement } from '../core/position.ts';\nimport { Button, type ButtonProps } from './button.tsx';\nimport { Tooltip } from './tooltip.tsx';\nimport { BadgeIndicator } from './badge-indicator.tsx';\nimport { badgeText } from '../core/badge-indicator.ts';\nimport { cn } from './lib/utils.ts';\n\n/**\n * Carbon `IconButton` as a React + Tailwind component, as `<ui-icon-button>`: a square icon-only\n * Button (ghost by default) named by its icon tooltip — `label` is both the accessible name and the\n * tooltip text, shown below by default (`tooltipPlacement`).\n */\nexport interface IconButtonProps extends Omit<ButtonProps, 'iconOnly' | 'icon' | 'children' | 'size'> {\n    /** Required: the accessible name and the tooltip text. */\n    label: string;\n    /** Carbon IconButton sizes: sm 32 · md 40 · lg 48px (no xl / 2xl, unlike Button). */\n    size?: 'sm' | 'md' | 'lg';\n    /** Where the tooltip goes (Carbon `align`, every value): top, bottom, left, right, each with `-start` / `-end`. */\n    tooltipPlacement?: Placement;\n    /** The 16px icon. */\n    children: ReactNode;\n    /** A badge in the corner (Carbon `badgeCount`, for a ghost lg button): 0 a dot, a number a count read as the description. Hidden while disabled. */\n    badgeCount?: number;\n}\n\nexport function IconButton({ label, tooltipPlacement = 'bottom', kind = 'ghost', badgeCount, size, disabled, className, children, ...rest }: Readonly<IconButtonProps>) {\n    const badgeId = useId();\n    const badge = badgeCount !== undefined && !disabled;\n    const described = badge && badgeText(badgeCount) !== '';\n    return (\n        <Tooltip text={label} asLabel placement={tooltipPlacement}>\n            <Button aria-describedby={described ? badgeId : undefined} {...rest} size={size} disabled={disabled} kind={kind} iconOnly className={cn(badge && 'relative', className)}>\n                {children}\n                {badge ? <BadgeIndicator id={badgeId} count={badgeCount} className={size === 'sm' && !described ? 'mt-1 me-1' : undefined} /> : null}\n            </Button>\n        </Tooltip>\n    );\n}\n"
    }
  ]
}
