SPB Git forge

spb/polyllm

Public
15commits 1branches 0releases
2.2 MBsize
maindefault branch
13 days agolast push
TypeScript 97.4% SQL 1% JavaScript 0.9% CSS 0.6%
1.2 KB · 19 lines tsx
Raw Blame History
1"use client";2import * as React from "react";3import * as SwitchPrimitive from "@radix-ui/react-switch";4import { cn } from "@/lib/utils";56export const Switch = React.forwardRef<React.ElementRef<typeof SwitchPrimitive.Root>, React.ComponentPropsWithoutRef<typeof SwitchPrimitive.Root> & { size?: "sm" | "md" }>(function Switch({ className, size = "md", ...props }, ref) {7  const dims = size === "sm" ? "h-4 w-7" : "h-5 w-9";8  const thumb = size === "sm" ? "size-3 data-[state=checked]:translate-x-3" : "size-4 data-[state=checked]:translate-x-4";9  return (10    <SwitchPrimitive.Root11      ref={ref}12      className={cn("peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-accent data-[state=unchecked]:bg-border-strong", dims, className)}13      {...props}14    >15      <SwitchPrimitive.Thumb className={cn("pointer-events-none block rounded-full bg-white shadow-sm ring-0 transition-transform data-[state=unchecked]:translate-x-0", thumb)} />16    </SwitchPrimitive.Root>17  );18});19