Glass Checkbox
einui/glass-checkboxFreeComponent
A liquid glass styled checkbox with animated check indicator.
Live preview
live · rendered by the registry
Rendered by einui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.eindev.ir/r/glass-checkbox.jsonSource
1"use client"23import * as React from "react"4import * as CheckboxPrimitive from "@radix-ui/react-checkbox"5import { motion, type Variants } from "framer-motion"6import { Check } from "lucide-react"7import { cn } from "@/lib/utils"89const checkVariants: Variants = {10 initial: { scale: 0, opacity: 0 },11 checked: {12 scale: 1,13 opacity: 1,14 transition: {15 type: "spring",16 duration: 0.2,17 bounce: 0.5,18 },19 },20 unchecked: {21 scale: 0,22 opacity: 0,23 transition: {24 duration: 0.1,25 },26 },27}2829export interface GlassCheckboxProps extends React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> {30 label?: string31}3233const GlassCheckbox = React.forwardRef<React.ElementRef<typeof CheckboxPrimitive.Root>, GlassCheckboxProps>(34 ({ className, label, id, ...props }, ref) => {35 const checkboxId = id || "glass-checkbox-id"3637 return (38 <div className="flex items-center gap-3">39 <CheckboxPrimitive.Root40 ref={ref}41 id={checkboxId}42 className={cn(43 "peer h-5 w-5 shrink-0 rounded-md",44 "bg-white/10 backdrop-blur-xl border border-white/30",45 "shadow-[0_2px_8px_rgba(0,0,0,0.2)]",46 "transition-all duration-200",47 "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cyan-400/50 focus-visible:ring-offset-2 focus-visible:ring-offset-transparent",48 "disabled:cursor-not-allowed disabled:opacity-50",49 "data-[state=checked]:bg-linear-to-r data-[state=checked]:from-cyan-500/60 data-[state=checked]:to-blue-500/60",50 "data-[state=checked]:border-white/40",51 className,52 )}53 {...props}54 >55 <CheckboxPrimitive.Indicator className={cn("flex items-center justify-center text-white")} asChild>56 <motion.div variants={checkVariants} initial="initial" animate="checked" exit="unchecked">57 <Check className="h-3.5 w-3.5" strokeWidth={3} />58 </motion.div>59 </CheckboxPrimitive.Indicator>60 </CheckboxPrimitive.Root>61 {label && (62 <label63 htmlFor={checkboxId}64 className="text-sm font-medium text-white/80 cursor-pointer select-none peer-disabled:cursor-not-allowed peer-disabled:opacity-50"65 >66 {label}67 </label>68 )}69 </div>70 )71 },72)73GlassCheckbox.displayName = CheckboxPrimitive.Root.displayName7475export { GlassCheckbox }
What it pulls in
npm packages
Files it writes
More from einui
All 44 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Base Widgetbase-widget | einui | Components | Free | 1 dep | |
| Calendar Widgetscalendar-widget | einui | Components | Free | 1 dep | |
| Clock Widgetsclock-widget | einui | Components | Free | 1 dep | |
| Glass Alert Dialogglass-alert-dialog | einui | Components | Free | 1 dep | |
| Glass Avatarglass-avatar | einui | Components | Free | 1 dep | |
| Glass Badgeglass-badge | einui | Components | Free | 1 dep | |
| Glass Breadcrumbglass-breadcrumb | einui | Components | Free | 1 dep | |
| Glass Buttonglass-button | einui | Components | Free | 2 deps |
