Checkbox
Styled checkbox component built on the zw-checkbox primitive.
@zeus-web/checkboxData Entryzweb add checkboxGenerated
Playground
Source
Choose the framework entry that matches your application.
html
<script type="module">
import '@zeus-web/checkbox/wc/auto'
</script>
<zw-checkbox default-checked>Enable notifications</zw-checkbox>tsx
import { Checkbox } from '@zeus-web/checkbox/react'
export function CheckboxExample() {
return <Checkbox defaultChecked>Enable notifications</Checkbox>
}vue
<script setup lang="ts">
import { Checkbox } from '@zeus-web/checkbox/vue'
</script>
<template>
<Checkbox default-checked>Enable notifications</Checkbox>
</template>Add
bash
zweb add checkboxImports
Styled registry component:
tsx
import { Checkbox } from '@/components/ui/checkbox'Primitive React wrapper:
tsx
import { Checkbox } from '@zeus-web/checkbox/react'Web Component entry:
ts
import '@zeus-web/checkbox/wc/auto'Props
| Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | - | Controlled checked state. |
defaultChecked | boolean | - | Initial checked state. |
indeterminate | boolean | - | Mixed state. |
size | CheckboxSizeValues: sm, md, lg | md | Checkbox size. |
required | boolean | - | Marks the checkbox as required. |
ariaLabel | string | - | Accessible label for unlabeled checkboxes. |
ariaDescribedby | string | - | ID reference for additional accessible description. |
Events
| Event | React prop | Detail | Description |
|---|---|---|---|
checked-change | onCheckedChange | checked: boolean, nativeEvent: Event | Emitted when checked state changes. |
focus-change | onFocusChange | focused: boolean, nativeEvent: FocusEvent | Emitted when focus state changes. |
Slots
| Slot | Description |
|---|---|
default | Label content. |
indicator | Custom indicator content. |
Styling
Uses Tailwind: yes
Theme tokens:
bg-primarytext-primary-foregroundring-ring
Internal selectors:
[&_[data-slot=checkbox-control]][&_[data-slot=checkbox-indicator]]
Registry
Registry source: available.
Add command: zweb add checkbox
Type: component
Dependencies:
@zeus-web/checkboxclass-variance-authority
Registry dependencies:
cnglobals
Files:
templates/react/checkbox.tsx→components/ui/checkbox.tsxtemplates/vue/checkbox.ts→components/ui/checkbox.ts
AI usage rules
Do:
- Use Checkbox for boolean form choices.
- Use indeterminate for mixed state.
Do not:
- Do not render a separate native input next to Checkbox.
- Do not manually manage aria-checked when using the primitive props.
Examples
React styled usage
tsx
import { Checkbox } from '@/components/ui/checkbox'
export function Example() {
return <Checkbox>Accept terms</Checkbox>
}