UNPKG

@arolariu/components

Version:

🎨 60+ 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! ⚡

43 lines (42 loc) • 1.69 kB
"use client"; import { jsx } from "react/jsx-runtime"; import { createContext, useContext } from "react"; import { Item, Root } from "@radix-ui/react-toggle-group"; import { cn } from "../../lib/utils.js"; import { toggleVariants } from "./toggle.js"; const ToggleGroupContext = /*#__PURE__*/ createContext({ size: "default", variant: "default" }); function ToggleGroup({ className, variant, size, children, ...props }) { return /*#__PURE__*/ jsx(Root, { "data-slot": "toggle-group", "data-variant": variant, "data-size": size, className: cn("group/toggle-group flex w-fit items-center rounded-md data-[variant=outline]:shadow-xs", className), ...props, children: /*#__PURE__*/ jsx(ToggleGroupContext.Provider, { value: { variant, size }, children: children }) }); } function ToggleGroupItem({ className, children, variant, size, ...props }) { const context = useContext(ToggleGroupContext); return /*#__PURE__*/ jsx(Item, { "data-slot": "toggle-group-item", "data-variant": context.variant || variant, "data-size": context.size || size, className: cn(toggleVariants({ variant: context.variant || variant, size: context.size || size }), "min-w-0 flex-1 shrink-0 rounded-none shadow-none first:rounded-l-md last:rounded-r-md focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0 data-[variant=outline]:first:border-l", className), ...props, children: children }); } export { ToggleGroup, ToggleGroupItem }; //# sourceMappingURL=toggle-group.js.map