{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "toggle-group",
  "title": "Toggle Group",
  "description": "Set of toggles that act as a single or multiple choice, built on Radix.",
  "dependencies": [
    "class-variance-authority@^0.7.1",
    "radix-ui@^1.6.7"
  ],
  "registryDependencies": [
    "@pestoui/style",
    "@pestoui/toggle",
    "@pestoui/utils"
  ],
  "files": [
    {
      "path": "pestoui/ui/toggle-group.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { type VariantProps } from \"class-variance-authority\"\nimport { ToggleGroup as ToggleGroupPrimitive } from \"radix-ui\"\n\nimport { cn } from \"@/lib/utils\"\nimport { toggleVariants } from \"@/components/ui/toggle\"\n\nconst ToggleGroupContext = React.createContext<\n  VariantProps<typeof toggleVariants> & {\n    spacing?: number\n    orientation?: \"horizontal\" | \"vertical\"\n  }\n>({\n  size: \"default\",\n  variant: \"default\",\n  spacing: 2,\n  orientation: \"horizontal\",\n})\n\nfunction ToggleGroup({\n  className,\n  variant,\n  size,\n  spacing = 2,\n  orientation = \"horizontal\",\n  children,\n  ...props\n}: React.ComponentProps<typeof ToggleGroupPrimitive.Root> &\n  VariantProps<typeof toggleVariants> & {\n    spacing?: number\n    orientation?: \"horizontal\" | \"vertical\"\n  }) {\n  return (\n    <ToggleGroupPrimitive.Root\n      data-slot=\"toggle-group\"\n      data-variant={variant}\n      data-size={size}\n      data-spacing={spacing}\n      data-orientation={orientation}\n      style={{ \"--gap\": spacing } as React.CSSProperties}\n      className={cn(\n        \"group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-[11px] data-[size=sm]:rounded-[9px] data-vertical:flex-col data-vertical:items-stretch\",\n        className\n      )}\n      {...props}\n    >\n      <ToggleGroupContext.Provider\n        value={{ variant, size, spacing, orientation }}\n      >\n        {children}\n      </ToggleGroupContext.Provider>\n    </ToggleGroupPrimitive.Root>\n  )\n}\n\nfunction ToggleGroupItem({\n  className,\n  children,\n  variant = \"default\",\n  size = \"default\",\n  ...props\n}: React.ComponentProps<typeof ToggleGroupPrimitive.Item> &\n  VariantProps<typeof toggleVariants>) {\n  const context = React.useContext(ToggleGroupContext)\n\n  return (\n    <ToggleGroupPrimitive.Item\n      data-slot=\"toggle-group-item\"\n      data-variant={context.variant || variant}\n      data-size={context.size || size}\n      data-spacing={context.spacing}\n      className={cn(\n        // Segmented items sit flush against each other, so the press scale is\n        // pulled back — a full-strength squish would open a visible seam.\n        \"shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 group-data-[spacing=0]/toggle-group:active:scale-[0.98] focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t\",\n        toggleVariants({\n          variant: context.variant || variant,\n          size: context.size || size,\n        }),\n        // The Switch's lean, for a choice of one: while a sibling is held, the\n        // selected item leans half a lean toward it — the selection about to\n        // move, shown before it does. Half, because it is a whole item moving\n        // rather than a knob inside a track. Radio items only (single mode),\n        // and never when flush (spacing 0), where any travel opens a seam.\n        // Both selector directions are spelled per axis and per writing\n        // direction, because `translate` is physical and the next sibling is\n        // on the left in RTL. Direction is read off the group root's own `dir`\n        // attribute: Radix always writes one there (`ltr` unless the `dir`\n        // prop or a DirectionProvider says otherwise), and it is the nearest\n        // `dir` above every item, so it is the direction the row is laid out\n        // in. Not `:dir()` — the production build lowers it to a `:lang()`\n        // list, which leans an RTL row on an English page the wrong way and\n        // costs ~3.4 kB — and not Tailwind's `rtl:`, which also matches\n        // through any RTL ancestor and would lean an LTR group inside an RTL\n        // page the wrong way. The trade-off of an attribute selector is that it\n        // cannot see a `dir` written below the root: an item given its own\n        // `dir` (a nested island inside its row) still follows the root, which\n        // is the right call, since the item's position in the row is the\n        // root's to decide.\n        \"group-data-horizontal/toggle-group:not-data-[spacing=0]:data-[state=on]:group-not-[[dir=rtl]]/toggle-group:[&[role=radio]:has(~[role=radio]:active)]:translate-x-[calc(var(--press-lean)/2)] group-data-horizontal/toggle-group:not-data-[spacing=0]:data-[state=on]:group-not-[[dir=rtl]]/toggle-group:[[role=radio]:active~&[role=radio]]:translate-x-[calc(var(--press-lean)/-2)] group-data-horizontal/toggle-group:not-data-[spacing=0]:data-[state=on]:group-[[dir=rtl]]/toggle-group:[&[role=radio]:has(~[role=radio]:active)]:translate-x-[calc(var(--press-lean)/-2)] group-data-horizontal/toggle-group:not-data-[spacing=0]:data-[state=on]:group-[[dir=rtl]]/toggle-group:[[role=radio]:active~&[role=radio]]:translate-x-[calc(var(--press-lean)/2)] group-data-vertical/toggle-group:not-data-[spacing=0]:data-[state=on]:[&[role=radio]:has(~[role=radio]:active)]:translate-y-[calc(var(--press-lean)/2)] group-data-vertical/toggle-group:not-data-[spacing=0]:data-[state=on]:[[role=radio]:active~&[role=radio]]:translate-y-[calc(var(--press-lean)/-2)]\",\n        // toggleVariants' own transition lists with `translate` appended on the\n        // press spring, so the lean eases out and back like the squeeze does.\n        // Restated whole and placed after toggleVariants so it replaces that\n        // list rather than tying with it — keep the first four in step with\n        // toggle.tsx.\n        \"[transition-property:color,background-color,border-color,scale,translate] [transition-duration:var(--duration-base),var(--duration-base),var(--duration-base),var(--duration-spring-press),var(--duration-spring-press)] [transition-timing-function:var(--ease-out-expo),var(--ease-out-expo),var(--ease-out-expo),var(--ease-spring-press),var(--ease-spring-press)]\",\n        className\n      )}\n      {...props}\n    >\n      {children}\n    </ToggleGroupPrimitive.Item>\n  )\n}\n\nexport { ToggleGroup, ToggleGroupItem }\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}