MicroClub Checkbox
mcoli-ui-registry/mc-checkboxFreeComponent
A checkbox component for MicroClub UI
Live preview
live · rendered by the registry
Rendered by mcoli-ui-registry on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://mcoli-ui.microclub.info/r/mc-checkbox.jsonSource
1'use client';23import * as React from 'react';4import { Checkbox as CheckboxPrimitive } from '@base-ui/react/checkbox';5import { cva, type VariantProps } from 'class-variance-authority';6import { CheckIcon } from 'lucide-react';78import { cn } from '@/lib/utils';910const checkboxVariants = cva(11 'peer relative flex shrink-0 items-center justify-center rounded-[4px] border transition-colors outline-none disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50',12 {13 variants: {14 size: {15 sm: 'size-4 [&_[data-slot=checkbox-indicator]>svg]:size-3',16 md: 'size-5 [&_[data-slot=checkbox-indicator]>svg]:size-3.5',17 },18 },19 defaultVariants: {20 size: 'sm',21 },22 }23);2425const textVariants = cva('font-medium transition-colors', {26 variants: {27 size: {28 sm: 'text-sm',29 md: 'text-base',30 },31 disabled: {32 true: 'text-muted-foreground',33 false: 'text-foreground',34 },35 },36 defaultVariants: {37 size: 'sm',38 disabled: false,39 },40});4142const supportTextVariants = cva('font-regular', {43 variants: {44 size: {45 sm: 'text-sm',46 md: 'text-base',47 },48 },49 defaultVariants: {50 size: 'sm',51 },52});5354export interface McCheckboxProps55 extends CheckboxPrimitive.Root.Props, VariantProps<typeof checkboxVariants> {56 text?: string;57 supportText?: string;58}5960function McCheckbox({61 className,62 size = 'sm',63 text,64 supportText,65 id,66 disabled,67 checked,68 onCheckedChange,69 ...props70}: McCheckboxProps) {71 const checkboxId = React.useId();72 const finalId = id ?? checkboxId;73 const labelId = text ? `${finalId}-label` : undefined;74 const descriptionId = supportText ? `${finalId}-description` : undefined;7576 return (77 <label78 htmlFor={finalId}79 className={cn(80 'inline-flex',81 size === 'sm' ? 'gap-2' : 'gap-3',82 supportText ? 'items-start' : 'items-center',83 disabled ? 'cursor-not-allowed' : 'cursor-pointer',84 className85 )}86 >87 <CheckboxPrimitive.Root88 id={finalId}89 data-slot="checkbox"90 className={cn(91 checkboxVariants({ size }),92 'self-start mt-0.5',93 'bg-primary-foreground border-muted-foreground',94 'hover:border-primary',95 'focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-ring',96 'focus-within:outline-none focus-within:ring-4 focus-within:ring-ring',97// … truncated
What it pulls in
npm packages
Files it writes
More from mcoli-ui-registry
All 42 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| MicroClub Accordionmc-accordion | mcoli-ui-registry | Components | Free | 2 deps | |
| MicroClub Alertmc-alert | mcoli-ui-registry | Components | Free | 1 dep | |
| MicroClub Alert Dialogmc-alert-dialog | mcoli-ui-registry | Components | Free | 1 dep | |
| MicroClub Avatarmc-avatar | mcoli-ui-registry | Components | Free | 1 dep | |
| MicroClub Badgemc-badge | mcoli-ui-registry | Components | Free | 1 dep | |
| MicroClub Breadcrumbmc-breadcrumb | mcoli-ui-registry | Components | Free | 2 deps | |
| MicroClub Buttonmc-button | mcoli-ui-registry | Components | Free | 2 deps | |
| MicroClub Calendarmc-calendar | mcoli-ui-registry | Components | Free | 3 deps |
