Checkbox
animate-ui/components-base-checkboxFreeComponent
An easily stylable checkbox component.
Install it
npx shadcn@latest add https://animate-ui.com/r/components-base-checkbox.jsonSource
1import * as React from 'react';23import {4 Checkbox as CheckboxPrimitive,5 CheckboxIndicator as CheckboxIndicatorPrimitive,6 type CheckboxProps as CheckboxPrimitiveProps,7} from '@/components/animate-ui/primitives/base/checkbox';8import { cn } from '@/lib/utils';9import { cva, type VariantProps } from 'class-variance-authority';1011const checkboxVariants = cva(12 'peer shrink-0 flex items-center justify-center outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 disabled:cursor-not-allowed disabled:opacity-50 transition-colors duration-500 focus-visible:ring-offset-2 [&[data-checked],&[data-indeterminate]]:bg-primary [&[data-checked],&[data-indeterminate]]:text-primary-foreground',13 {14 variants: {15 variant: {16 default: 'bg-background border',17 accent: 'bg-input',18 },19 size: {20 default: 'size-5 rounded-sm',21 sm: 'size-4.5 rounded-[5px]',22 lg: 'size-6 rounded-[7px]',23 },24 },25 defaultVariants: {26 variant: 'default',27 size: 'default',28 },29 },30);3132const checkboxIndicatorVariants = cva('', {33 variants: {34 size: {35 default: 'size-3.5',36 sm: 'size-3',37 lg: 'size-4',38 },39 },40 defaultVariants: {41 size: 'default',42 },43});4445type CheckboxProps = CheckboxPrimitiveProps &46 VariantProps<typeof checkboxVariants> & {47 children?: React.ReactNode;48 };4950function Checkbox({51 className,52 children,53 variant,54 size,55 ...props56}: CheckboxProps) {57 return (58 <CheckboxPrimitive59 className={cn(checkboxVariants({ variant, size, className }))}60 {...props}61 >62 {children}63 <CheckboxIndicatorPrimitive64 className={cn(checkboxIndicatorVariants({ size }))}65 />66 </CheckboxPrimitive>67 );68}6970export { Checkbox, type CheckboxProps };
What it pulls in
npm packages
Other registry items
Files it writes
More from Animate UI
All 580 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Avatar Groupcomponents-animate-avatar-group | Animate UI | Components | Free | 1 dep | |
| Codecomponents-animate-code | Animate UI | Components | Free | 1 dep | |
| Code Tabscomponents-animate-code-tabs | Animate UI | Components | Free | 1 dep | |
| Cursorcomponents-animate-cursor | Animate UI | Components | Free | no deps | |
| GitHub Stars Wheelcomponents-animate-github-stars-wheel | Animate UI | Components | Free | 1 dep | |
| Tabscomponents-animate-tabs | Animate UI | Components | Free | no deps | |
| Tooltipcomponents-animate-tooltip | Animate UI | Components | Free | 1 dep | |
| Bubble Backgroundcomponents-backgrounds-bubble | Animate UI | Components | Free | 1 dep |
