Download apps/vscode/webview-ui/src/components/ui/switch.tsx from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 1.94 kB
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/apps/vscode/webview-ui/src/components/ui/switch.tsx
- Command line
-
hf download hf://SaylorTwift/kimi-code/apps/vscode/webview-ui/src/components/ui/switch.tsx
-
curl -L -o switch.tsx https://huggingface.co/SaylorTwift/kimi-code/resolve/main/apps/vscode/webview-ui/src/components/ui/switch.tsx
1.94 kB
| import * as React from "react"; | |
| import { Switch as SwitchPrimitive } from "radix-ui"; | |
| import { cn } from "@/lib/utils"; | |
| function Switch({ | |
| className, | |
| size = "default", | |
| variant = "default", | |
| ...props | |
| }: React.ComponentProps<typeof SwitchPrimitive.Root> & { | |
| size?: "sm" | "default"; | |
| variant?: "default" | "blue"; | |
| }) { | |
| return ( | |
| <SwitchPrimitive.Root | |
| data-slot="switch" | |
| data-size={size} | |
| className={cn( | |
| // base | |
| "data-unchecked:bg-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 dark:data-unchecked:bg-input/80 shrink-0 rounded-full border border-transparent focus-visible:ring-[3px] aria-invalid:ring-[3px] data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] peer group/switch relative inline-flex items-center transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 data-disabled:cursor-not-allowed data-disabled:opacity-50", | |
| // variants | |
| variant === "default" && "data-checked:bg-primary", | |
| variant === "blue" && "data-checked:bg-blue-400", | |
| className, | |
| )} | |
| {...props} | |
| > | |
| <SwitchPrimitive.Thumb | |
| data-slot="switch-thumb" | |
| className="bg-background dark:data-unchecked:bg-foreground dark:data-checked:bg-primary-foreground rounded-full group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 pointer-events-none block ring-0 transition-transform" | |
| /> | |
| </SwitchPrimitive.Root> | |
| ); | |
| } | |
| export { Switch }; | |