{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-group",
  "title": "Button Group",
  "description": "Segmented cluster of buttons that share edges, with optional separators.",
  "dependencies": [
    "class-variance-authority@^0.7.1"
  ],
  "registryDependencies": [
    "@pestoui/separator",
    "@pestoui/style",
    "@pestoui/utils"
  ],
  "files": [
    {
      "path": "pestoui/ui/button-group.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Separator } from \"@/components/ui/separator\"\n\n/* A segmented cluster of real <Button>s that share edges.\n *\n * The children stay untouched Buttons — every variant, size and state keeps\n * working — and the wrapper rewrites only the shared edges from the outside:\n *\n *   · horizontally the ends stay rounded-lg: the first child keeps its leading\n *     radius, the last keeps its trailing one, everything between squares off\n *   · vertically the ends clamp to rounded-lg instead. A stacked child is wide\n *     and short, so rounded-full on its top two corners only gets scaled up\n *     until it eats the whole edge — the pill domes into an arch. This is the\n *     radius-collapse failure mode, and a stack reads as a full-width control\n *     anyway, which squares to rounded-lg\n *   · icon segments opt out of that clamp. They are square, so there is no arch\n *     to fix, and rounded-lg is a token radius (--radius, 1rem) landing on a\n *     36-40px box: fatter than the squircle Button asked for, and one bump of\n *     --radius away from collapsing the outer edge into a circle. They keep\n *     their own explicit pixel radius instead\n *   · each non-leading child drops the border on its shared edge, so two 1px\n *     hairlines collapse into one instead of stacking into a 2px seam\n *   · the child sitting before a ButtonGroupSeparator drops its trailing border\n *     as well, leaving the separator as the only hairline at that joint\n *   · Button's press feedback is neutralised — both halves of it. A cluster has\n *     to move as one piece: a single segment dropping 1px tears the shared edge\n *     open, and its press scale does the same thing twice as badly, since a\n *     segment shrinking toward its own centre pulls *both* of its edges inward\n *     and opens a gap on either side of it. Neither is a per-segment gesture\n *     once the segments share a border\n *   · the press is handed back to the group instead, which is the only element\n *     that can carry it without a seam to tear. It is a far smaller scale than\n *     a lone Button's — the cluster is several times the width, and equal\n *     percentages do not read as equal movement at different sizes\n *\n * \"Untouched Buttons\" is about what the wrapper does to a child, not about what\n * a child is allowed to be. A child that renders NO DOM of its own is legal,\n * and is how a split button gets built: DropdownMenu.Root emits no element, so\n * with `asChild` on its trigger the Button underneath is the group's real\n * element child and every rule above still lands on it. Measured on the docs\n * page: the group keeps three element children (button, separator, button), the\n * trigger still matches `:last-child` and keeps its trailing radius, and still\n * drops its left border as `:not(:first-child)`. The line to watch is the other\n * one — a wrapper that DOES emit an element becomes the child, and the radius\n * and border rewrites land on the wrapper while the Button inside keeps all\n * four of its own corners and borders.\n *\n * The child selectors land at (0,2,0) or better, which outranks Button's own\n * `rounded-lg` / `border` (0,1,0) without reaching for !important. The two\n * neutralising rules are the exception: Button qualifies its press with enough\n * :not() guards to outrank them on specificity, so those carry the flag. */\nconst buttonGroupVariants = cva(\n  \"group/button-group isolate flex w-fit items-stretch transition-transform duration-fast ease-out-expo has-[:active]:scale-99 has-[:active]:duration-spring-press has-[:active]:ease-spring-press [&>*]:relative [&>*]:active:translate-y-0! [&>*]:active:scale-none! [&>*]:hover:z-10 [&>*]:focus-visible:z-10\",\n  {\n    variants: {\n      orientation: {\n        horizontal:\n          \"flex-row rounded-lg [&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none [&>*:has(+[data-slot=button-group-separator])]:border-r-0\",\n        vertical:\n          \"flex-col rounded-lg [&>*:not([data-size^='icon']):first-child]:rounded-t-lg [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not([data-size^='icon']):last-child]:rounded-b-lg [&>*:not(:last-child)]:rounded-b-none [&>*:has(+[data-slot=button-group-separator])]:border-b-0\",\n      },\n    },\n    defaultVariants: {\n      orientation: \"horizontal\",\n    },\n  }\n)\n\nconst ButtonGroupContext = React.createContext<{\n  orientation: \"horizontal\" | \"vertical\"\n}>({ orientation: \"horizontal\" })\n\nfunction ButtonGroup({\n  className,\n  orientation = \"horizontal\",\n  children,\n  ...props\n}: React.ComponentProps<\"div\"> &\n  VariantProps<typeof buttonGroupVariants> & {\n    orientation?: \"horizontal\" | \"vertical\"\n  }) {\n  return (\n    <div\n      data-slot=\"button-group\"\n      data-orientation={orientation}\n      role=\"group\"\n      className={cn(buttonGroupVariants({ orientation }), className)}\n      {...props}\n    >\n      <ButtonGroupContext.Provider value={{ orientation }}>\n        {children}\n      </ButtonGroupContext.Provider>\n    </div>\n  )\n}\n\n/* Hairline between two segments. Decorative by default (role=\"none\") — the\n * buttons either side already carry their own accessible names.\n *\n * It runs perpendicular to the group, which it reads from context rather than\n * from a CSS override: `group-data-vertical/*` compiles down to (0,1,0) and\n * sorts ahead of Separator's own `data-vertical:w-px`, so an override there\n * would lose the tie and leave a 1px sliver in a vertical group. */\nfunction ButtonGroupSeparator({\n  className,\n  orientation,\n  ...props\n}: React.ComponentProps<typeof Separator>) {\n  const group = React.useContext(ButtonGroupContext)\n  const resolved =\n    orientation ?? (group.orientation === \"vertical\" ? \"horizontal\" : \"vertical\")\n\n  return (\n    <Separator\n      data-slot=\"button-group-separator\"\n      orientation={resolved}\n      decorative\n      className={cn(\"bg-border\", className)}\n      {...props}\n    />\n  )\n}\n\nexport { ButtonGroup, ButtonGroupSeparator, buttonGroupVariants }\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}