GooseUI

Components

Checkbox


Native checkbox with an animated check mark, no JavaScript

Checkbox wraps a native checkbox in a label and animates its SVG check mark with CSS. It accepts input attributes including name, required, checked and disabled, with three colors and three sizes. Use it for independent choices; Radio is intended for choosing one option from a group.

Browser Support

:has()

Animates the checked state.

Your browser:

Preview

Installation

npx shadcn@latest add @gooseui/checkbox
pnpm dlx shadcn@latest add @gooseui/checkbox
yarn dlx shadcn@latest add @gooseui/checkbox
bunx --bun shadcn@latest add @gooseui/checkbox

Usage

import { Checkbox } from "@/components/ui/checkbox"

export function MyComponent() {
  return <Checkbox label="Accept terms" />
}

Variants

<Checkbox variant="default" label="Default" />
<Checkbox variant="destructive" label="Destructive" />
<Checkbox variant="success" label="Success" />

Sizes

<Checkbox size="sm" label="Small" />
<Checkbox size="default" label="Default" />
<Checkbox size="lg" label="Large" />

Without Label

<Checkbox size="sm" />
<Checkbox size="default" />
<Checkbox size="lg" />

In a form

Pass any input attribute: name, value, required, defaultChecked or onChange in a client component. The form below works with JavaScript turned off.

import { Button } from "@/components/ui/button"

<form action={subscribe}>
  <Checkbox name="news" value="yes" label="Send me the newsletter" defaultChecked />
  <Checkbox name="terms" value="yes" label="I accept the terms" required />
  <Button type="submit">Submit</Button>
</form>

Props

PropTypeDefaultDescription
variant"default" | "destructive" | "success""default"Visual style variant
size"sm" | "default" | "lg""default"Size of the checkbox
labelstringundefinedLabel text displayed next to checkbox
...propsInputHTMLAttributes-Any other attribute goes to the native input