UNPKG

@arolariu/components

Version:

🎨 70+ beautiful, accessible React components built on Radix UI. TypeScript-first, tree-shakeable, SSR-ready. Perfect for modern web apps, design systems & rapid prototyping. Zero config, maximum flexibility! ⚡

39 lines (38 loc) • 1.41 kB
"use client"; import { jsx } from "react/jsx-runtime"; import { Item, Root } from "@radix-ui/react-toggle-group"; import { createContext, forwardRef, useContext } from "react"; import { toggleVariants } from "./toggle.js"; import { cn } from "../../lib/utilities.js"; const ToggleGroupContext = /*#__PURE__*/ createContext({ size: "default", variant: "default" }); const ToggleGroup = /*#__PURE__*/ forwardRef(({ className, variant, size, children, ...props }, ref)=>/*#__PURE__*/ jsx(Root, { ref: ref, className: cn("flex items-center justify-center gap-1", className), ...props, children: /*#__PURE__*/ jsx(ToggleGroupContext.Provider, { value: { variant, size }, children: children }) })); ToggleGroup.displayName = Root.displayName; const ToggleGroupItem = /*#__PURE__*/ forwardRef(({ className, children, variant, size, ...props }, ref)=>{ const context = useContext(ToggleGroupContext); return /*#__PURE__*/ jsx(Item, { ref: ref, className: cn(toggleVariants({ variant: context.variant || variant, size: context.size || size }), className), ...props, children: children }); }); ToggleGroupItem.displayName = Item.displayName; export { ToggleGroup, ToggleGroupItem }; //# sourceMappingURL=toggle-group.js.map