Skip to content

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 checkbox

Imports ​

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 ​

PropTypeDefaultDescription
checkedboolean-Controlled checked state.
defaultCheckedboolean-Initial checked state.
indeterminateboolean-Mixed state.
sizeCheckboxSize
Values: sm, md, lg
mdCheckbox size.
requiredboolean-Marks the checkbox as required.
ariaLabelstring-Accessible label for unlabeled checkboxes.
ariaDescribedbystring-ID reference for additional accessible description.

Events ​

EventReact propDetailDescription
checked-changeonCheckedChangechecked: boolean, nativeEvent: EventEmitted when checked state changes.
focus-changeonFocusChangefocused: boolean, nativeEvent: FocusEventEmitted when focus state changes.

Slots ​

SlotDescription
defaultLabel content.
indicatorCustom indicator content.

Styling ​

Uses Tailwind: yes

Theme tokens:

  • bg-primary
  • text-primary-foreground
  • ring-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/checkbox
  • class-variance-authority

Registry dependencies:

  • cn
  • globals

Files:

  • templates/react/checkbox.tsx → components/ui/checkbox.tsx
  • templates/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>
}

Released under the MIT License.