mirror of
https://github.com/ershisan99/DevToysWeb.git
synced 2025-12-16 12:32:48 +00:00
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
"use client";
|
|
|
|
import * as React from "react";
|
|
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
|
|
|
|
import { cn } from "@/lib/style";
|
|
|
|
const ToggleGroup = React.forwardRef<
|
|
React.ElementRef<typeof ToggleGroupPrimitive.Root>,
|
|
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root>
|
|
>(({ className, ...props }, ref) => (
|
|
<ToggleGroupPrimitive.Root
|
|
ref={ref}
|
|
className={cn("flex items-center gap-2.5", className)}
|
|
{...props}
|
|
/>
|
|
));
|
|
|
|
ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
|
|
|
|
const ToggleGroupItem = React.forwardRef<
|
|
React.ElementRef<typeof ToggleGroupPrimitive.Item>,
|
|
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item>
|
|
>(({ className, children, ...props }, ref) => (
|
|
<ToggleGroupPrimitive.Item
|
|
ref={ref}
|
|
className={cn(
|
|
"focus-visible:ring-ring inline-flex h-10 items-center justify-center rounded-md bg-accent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-sky-600 data-[state=on]:text-white",
|
|
className
|
|
)}
|
|
{...props}
|
|
>
|
|
{children}
|
|
</ToggleGroupPrimitive.Item>
|
|
));
|
|
|
|
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
|
|
|
|
export { ToggleGroup, ToggleGroupItem };
|