Download src/components/ui/button.tsx from Zero124/VR-MEDIA: direct link, hf CLI and curl.
- Browser
- Download file 3.06 kB
-
https://huggingface.co/spaces/Zero124/VR-MEDIA/resolve/main/src/components/ui/button.tsx
- Command line
-
hf download hf://spaces/Zero124/VR-MEDIA/src/components/ui/button.tsx
-
curl -L -o button.tsx https://huggingface.co/spaces/Zero124/VR-MEDIA/resolve/main/src/components/ui/button.tsx
3.06 kB
| import * as React from "react" | |
| import { Slot } from "@radix-ui/react-slot" | |
| import { cva, type VariantProps } from "class-variance-authority" | |
| import { cn } from "@/lib/utils" | |
| /** | |
| * Buttons per Β§4 of the YouTube design system. | |
| * - 40px height, 20px radius (pill), 16px horizontal padding, Roboto 14px/500 | |
| * - Every variant defines hover, active/pressed and disabled states | |
| * - No shadows at rest; shadows are reserved for modals/dropdowns (Β§6) | |
| */ | |
| const buttonVariants = cva( | |
| "inline-flex items-center justify-center gap-2 whitespace-nowrap font-medium transition-colors duration-100 disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:ring-2 focus-visible:ring-[#3ea6ff] focus-visible:ring-offset-2 focus-visible:ring-offset-[#0f0f0f] aria-invalid:border-[#e1002d]", | |
| { | |
| variants: { | |
| variant: { | |
| // Primary CTA β #065FD4 β #3EA6FF hover β #0540AA pressed | |
| default: | |
| "bg-[#065fd4] text-white hover:bg-[#3ea6ff] active:bg-[#0540aa] disabled:bg-white/5 disabled:text-[#606060]", | |
| // Secondary β translucent white on dark surfaces | |
| secondary: | |
| "bg-white/[0.08] text-[#f1f1f1] hover:bg-white/[0.12] active:bg-white/[0.16] disabled:bg-white/[0.02] disabled:text-[#aaaaaa]", | |
| // Ghost / outlined β 1px hairline border, blue label | |
| outline: | |
| "border border-white/20 bg-transparent text-[#3ea6ff] hover:bg-[#065fd4]/[0.08] active:bg-[#065fd4]/[0.12] disabled:border-white/10 disabled:text-[#aaaaaa]", | |
| // Destructive β Error #E1002D β #FF0033 hover β #C30027 pressed | |
| destructive: | |
| "bg-[#e1002d] text-white hover:bg-[#ff0033] active:bg-[#c30027] disabled:bg-white/5 disabled:text-[#606060]", | |
| ghost: | |
| "bg-transparent text-[#eeeeee] hover:bg-white/[0.08] active:bg-white/[0.12] disabled:text-[#606060]", | |
| link: "bg-transparent text-[#3ea6ff] underline-offset-4 hover:underline hover:text-[#065fd4] active:text-[#0540aa] disabled:text-[#606060]", | |
| }, | |
| size: { | |
| // 40px pill is the system default | |
| default: "h-10 px-4 rounded-[20px] text-sm", | |
| sm: "h-8 px-3 rounded-[16px] text-[13.3px] gap-1.5", | |
| lg: "h-12 px-6 rounded-[24px] text-sm", | |
| // Icon button β circular, transparent, hover wash (Β§4 Icon Button) | |
| icon: "size-10 rounded-full p-0", | |
| "icon-sm": "size-8 rounded-full p-0", | |
| }, | |
| }, | |
| defaultVariants: { | |
| variant: "default", | |
| size: "default", | |
| }, | |
| } | |
| ) | |
| function Button({ | |
| className, | |
| variant, | |
| size, | |
| asChild = false, | |
| ...props | |
| }: React.ComponentProps<"button"> & | |
| VariantProps<typeof buttonVariants> & { | |
| asChild?: boolean | |
| }) { | |
| const Comp = asChild ? Slot : "button" | |
| return ( | |
| <Comp | |
| data-slot="button" | |
| className={cn(buttonVariants({ variant, size, className }))} | |
| {...props} | |
| /> | |
| ) | |
| } | |
| export { Button, buttonVariants } | |