Checkbox
weekendsuperhero-io-sistine/checkboxFreeComponent
A control that allows the user to toggle between checked and not checked with optional glass material.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/Weekendsuperhero-io/sistine/main/public/r/checkbox.jsonSource
1"use client";23import { Check } from "@phosphor-icons/react";4import { Checkbox as CheckboxPrimitive } from "radix-ui";5import * as React from "react";67import { type MaterialAxisProps, materialSurface, splitAxisProps } from "@/lib/material";8import { cn } from "@/lib/utils";910/* Role: bordered adaptive glass. */11const ROLE = {12 border: true,13};1415const Checkbox = React.forwardRef<16 React.ElementRef<typeof CheckboxPrimitive.Root>,17 React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> &18 MaterialAxisProps & {19 variant?: "default" | "glass";20 }21>(({ className, variant = "glass", ...props }, ref) => {22 const [axes, rest] = splitAxisProps(props);23 /* `glow` rides the CHECKED state on toggles — kept out of the materialSurface forward below. */24 const m = materialSurface(variant === "default" ? null : ROLE, {25 ...axes,26 glow: undefined,27 });2829 return (30 <CheckboxPrimitive.Root31 ref={ref}32 data-slot="checkbox"33 data-material={m?.["data-material"]}34 className={cn(35 m?.className,36 "peer h-4 w-4 shrink-0 rounded-sm border shadow transition-shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",37 m === null && "border-primary",38 m !== null && "data-[state=checked]:glass data-[state=checked]:border-[var(--glass-border)]",39 axes.glow && "data-[state=checked]:glass-glow transition duration-200",40 className,41 )}42 {...rest}43 >44 <CheckboxPrimitive.Indicator data-slot="checkbox-indicator" className={cn("flex items-center justify-center text-current")}>45 <Check className="h-4 w-4" />46 </CheckboxPrimitive.Indicator>47 </CheckboxPrimitive.Root>48 );49});50Checkbox.displayName = CheckboxPrimitive.Root.displayName;5152export { Checkbox };
What it pulls in
npm packages
Other registry items
Files it writes
More from weekendsuperhero-io/sistine
All 71 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | weekendsuperhero-io/sistine | Components | Free | 5 deps · 4 files | |
| Alertalert | weekendsuperhero-io/sistine | Components | Free | 3 deps · 4 files | |
| Alert Dialogalert-dialog | weekendsuperhero-io/sistine | Components | Free | 4 deps · 4 files | |
| Auto Foregroundauto-foreground | weekendsuperhero-io/sistine | Components | Free | no deps | |
| Avataravatar | weekendsuperhero-io/sistine | Components | Free | 4 deps · 4 files | |
| Badgebadge | weekendsuperhero-io/sistine | Components | Free | 4 deps · 4 files | |
| Breadcrumbbreadcrumb | weekendsuperhero-io/sistine | Components | Free | 5 deps · 4 files | |
| Buttonbutton | weekendsuperhero-io/sistine | Components | Free | 4 deps · 4 files |
