Checkbox
octane/checkboxFreeComponent
octane publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by octane on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://raw.githubusercontent.com/octanejs/octane/main/packages/shadcn/registry/checkbox.jsonSource
1// Base UI base checkbox — runs on the @octanejs/base-ui `Checkbox` primitive.2//3// THE CONDITIONAL UTILITIES ARE ADAPTED, NOT COPIED, and the reason is structural rather than4// stylistic. Base UI's Checkbox.Root renders a `<span role="checkbox">` — verified by rendering5// it, not assumed — with a visually-hidden native `<input>` alongside it for form submission.6// A `<span>` is never `:disabled`, so Tailwind's `disabled:` variant (which compiles to the7// `:disabled` pseudo-class) can NEVER match. The primitive publishes `data-disabled` instead:8//9// radix base: `disabled:opacity-50` -> matches, Root is a real button10// base-ui base: `data-disabled:opacity-50` <- what this file uses11//12// `data-checked:` needs no change — the radix base already uses that exact form, and Base UI13// emits `data-checked`/`data-unchecked` too. `focus-visible:` also stays: the span carries14// tabindex, so the native pseudo-class applies.15//16// UNVERIFIED PROVENANCE: the non-conditional utilities are taken from this package's radix base17// rather than transcribed from upstream's Base UI source.18import { Checkbox as CheckboxPrimitive } from '@octanejs/base-ui/checkbox';19import { CheckIcon } from '@octanejs/lucide';2021import { cn } from '@/lib/utils';2223export interface CheckboxProps extends Record<string, unknown> {24 className?: string;25}2627export function Checkbox({ className, ...props }: CheckboxProps) @{28 <CheckboxPrimitive.Root29 data-slot="checkbox"30 className={cn(31 'peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 data-disabled:cursor-not-allowed data-disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary',32 className,33 )}34 {...props}35 >36 <CheckboxPrimitive.Indicator37 data-slot="checkbox-indicator"38 className="grid place-content-center text-current transition-none [&>svg]:size-3.5"39 >40 <CheckIcon />41 </CheckboxPrimitive.Indicator>42 </CheckboxPrimitive.Root>43}
What it pulls in
npm packages
Other registry items
Files it writes
More from octane
All 44 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | octane | Components | Free | 2 deps | |
| Alertalert | octane | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | octane | Components | Free | 1 dep | |
| Aspect Ratioaspect-ratio | octane | Components | Free | no deps | |
| Avataravatar | octane | Components | Free | 1 dep | |
| Badgebadge | octane | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | octane | Components | Free | 1 dep | |
| Buttonbutton | octane | Components | Free | 2 deps |
