Checkbox
blode-ui/checkboxFreeComponent
A control that allows the user to toggle between checked and unchecked states.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/mblode/blode-ui/main/public/r/checkbox.jsonSource
1"use client";23import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox";4import * as React from "react";56import { cn } from "@/lib/utils";78import "./checkbox.css";910type CheckedState = boolean | "indeterminate";1112export interface CheckboxProps extends Omit<13 React.ComponentProps<typeof CheckboxPrimitive.Root>,14 "checked" | "defaultChecked" | "indeterminate" | "onCheckedChange"15> {16 checked?: CheckedState;17 defaultChecked?: CheckedState;18 hasError?: boolean;19 indeterminate?: boolean;20 onCheckedChange?: (checked: CheckedState) => void;21}2223const Checkbox = ({24 checked,25 className,26 defaultChecked,27 hasError,28 indeterminate,29 onCheckedChange,30 ...props31}: CheckboxProps) => {32 const resolvedIndeterminate =33 indeterminate ?? (checked === "indeterminate" || defaultChecked === "indeterminate");3435 return (36 <CheckboxPrimitive.Root37 aria-invalid={hasError || undefined}38 checked={checked === "indeterminate" ? false : checked}39 className={cn(40 "ft-checkbox peer relative inline-flex size-5 shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-[6px] bg-card align-middle shadow-input transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 data-disabled:cursor-not-allowed data-checked:text-primary-foreground data-indeterminate:text-primary-foreground data-disabled:opacity-50",41 className,42 )}43 data-slot="checkbox"44 defaultChecked={defaultChecked === "indeterminate" ? false : defaultChecked}45 indeterminate={resolvedIndeterminate}46 onCheckedChange={(nextChecked) => onCheckedChange?.(nextChecked)}47 render={(renderProps, state) => {48 let dataState: "indeterminate" | "checked" | "unchecked" = "unchecked";49 if (state.indeterminate) {50 dataState = "indeterminate";51 } else if (state.checked) {52 dataState = "checked";53 }54 return <span {...renderProps} data-state={dataState} />;55 }}56 {...props}57 >58 <CheckboxPrimitive.Indicator59 className="pointer-events-none flex items-center justify-center text-current"60 data-slot="checkbox-indicator"61 keepMounted62 >63 <svg aria-hidden="true" className="z-10 h-3 w-4" role="presentation" viewBox="0 0 17 18">64 <polyline65 className="ft-checkbox-polyline"66 fill="none"67 points="1 9 7 14 15 4"68 stroke="currentColor"69// … truncated
What it pulls in
npm packages
Files it writes
More from blode/ui
All 85 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | blode/ui | Components | Free | 2 deps | |
| Alertalert | blode/ui | Components | Free | no deps | |
| Alert Dialogalert-dialog | blode/ui | Components | Free | 1 dep | |
| Ask User Questionsask-user-questions | blode/ui | Components | Free | 1 dep | |
| Aspect Ratioaspect-ratio | blode/ui | Components | Free | 1 dep | |
| Attachmentattachment | blode/ui | Components | Free | 1 dep | |
| Autocompleteautocomplete | blode/ui | Components | Free | 1 dep | |
| Avataravatar | blode/ui | Components | Free | 1 dep |
