Aurora Checkbox & Radio
aurora-dinglebear-ai/aurora-checkboxFreeComponent
Aurora-styled native checkbox with mixed-state support, focus glow, and label-friendly semantics.
Install it
npx shadcn@latest add https://aurora.dinglebear.ai/r/aurora-checkbox.jsonSource
1"use client"23import * as React from "react"4import { Check, Minus } from "lucide-react"5import { cn } from "@/lib/utils"6import { Input } from "./input"78export interface CheckboxProps9 extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "children" | "onChange" | "size" | "type"> {10 checked?: boolean11 defaultChecked?: boolean12 /** Tri-state: render a dash instead of a tick (e.g. a partially-selected group). Visually overrides `checked`. */13 indeterminate?: boolean14 onChange?: React.ChangeEventHandler<HTMLInputElement>15 onCheckedChange?: (checked: boolean) => void16 /** Label content rendered next to the box. */17 children?: React.ReactNode18}1920function Checkbox({21 ref,22 checked,23 defaultChecked = false,24 indeterminate = false,25 onCheckedChange,26 children,27 className,28 disabled,29 id,30 style,31 onFocus,32 onBlur,33 onChange,34 ...props35}: CheckboxProps & { ref?: React.Ref<HTMLInputElement> }) {36 const generatedId = React.useId()37 const resolvedId = id ?? generatedId38 const isControlled = checked !== undefined39 const [internalChecked, setInternalChecked] = React.useState(defaultChecked)40 const [focused, setFocused] = React.useState(false)41 const inputRef = React.useRef<HTMLInputElement | null>(null)4243 const setRefs = React.useCallback(44 (node: HTMLInputElement | null) => {45 inputRef.current = node46 if (typeof ref === "function") {47 ref(node)48 } else if (ref) {49 ;(ref as React.MutableRefObject<HTMLInputElement | null>).current = node50 }51 },52 [ref]53 )5455 const currentChecked = Boolean(isControlled ? checked : internalChecked)56 const state = indeterminate ? "indeterminate" : currentChecked ? "checked" : "unchecked"5758 React.useEffect(() => {59 if (inputRef.current) {60 inputRef.current.indeterminate = indeterminate61 }62 }, [indeterminate])6364 const input = (65 <Input66 {...props}67 id={resolvedId}68 ref={setRefs}69 unstyled70 type="checkbox"71 disabled={disabled}72 className="sr-only"73 checked={isControlled ? currentChecked : undefined}74 defaultChecked={isControlled ? undefined : defaultChecked}75 onChange={(event) => {76 if (!isControlled) {77 setInternalChecked(event.target.checked)78 }79 onCheckedChange?.(event.target.checked)80 onChange?.(event)81 }}82 onFocus={(event) => {83 setFocused(true)84 onFocus?.(event)85 }}86 onBlur={(event) => {87 setFocused(false)88// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from aurora
All 176 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Aurora Accordionaurora-accordion | aurora | Components | Free | 2 deps | |
| Aurora Alert Dialogaurora-alert-dialog | aurora | Components | Free | 2 deps | |
| Aurora Aspect Ratioaurora-aspect-ratio | aurora | Components | Free | no deps | |
| Aurora Avataraurora-avatar | aurora | Components | Free | 1 dep | |
| Aurora Badgeaurora-badge | aurora | Components | Free | 2 deps | |
| Aurora Banneraurora-banner | aurora | Components | Free | 1 dep | |
| Aurora Breadcrumbaurora-breadcrumb | aurora | Components | Free | 2 deps | |
| Aurora Buttonaurora-button | aurora | Components | Free | 2 deps |
