Checkbox
Neobrutalist-styled checkbox built on reka-ui's CheckboxRoot primitive, with a check indicator.
Demo
Installation
pnpm dlx brutx-vue@latest add checkboxUsage
<script setup>
import { ref } from 'vue'
import { Checkbox } from 'brutx-ui-vue'
const checked = ref(false)
</script>
<template>
<div class="flex items-center gap-3">
<Checkbox v-model:checked="checked" />
<span class="text-sm font-bold">Accept terms</span>
</div>
</template>Variants
| Variant | Description |
|---|---|
default | Default background, standard foreground |
primary | Primary (coral) background |
secondary | Secondary (mint) background |
accent | Accent (yellow) background |
danger | Danger (red) background |
<template>
<Checkbox variant="primary" />
</template>Sizes
| Size | Description |
|---|---|
sm | Small |
default | Default |
lg | Large |
With Label
<script setup>
import { ref } from 'vue'
import { Checkbox, Label } from 'brutx-ui-vue'
const checked = ref(false)
</script>
<template>
<div class="flex items-center gap-3">
<Checkbox v-model:checked="checked" id="terms" />
<Label for="terms">Accept terms and conditions</Label>
</div>
</template>Disabled State
<script setup>
import { Checkbox } from 'brutx-ui-vue'
</script>
<template>
<Checkbox disabled />
</template>Indeterminate State
Set checked to 'indeterminate' to display the indeterminate state. The indicator shows a Minus icon, commonly used for "partially selected" hierarchical selection scenarios.
Uncontrolled mode supports it too: <Checkbox defaultValue="indeterminate" /> initially renders the Minus icon with aria-checked="mixed". Per reka-ui semantics, clicking switches the state to checked — it does not return to indeterminate automatically.
<script setup>
import { Checkbox } from 'brutx-ui-vue'
</script>
<template>
<Checkbox :checked="'indeterminate'" />
</template>API Reference
| Name | Type | Default | Description |
|---|---|---|---|
class | string | undefined | undefined | CSS classes added to the checkbox root interactive element. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/checkbox/Checkbox.vue | |||
checked | boolean | "indeterminate" | undefined | undefined | The controlled checked state: checked, unchecked, or indeterminate. When omitted, the component maintains its own state. |
DetailsDeclared typeboolean | "indeterminate" | undefined Literal values
Default value details
Sourcepackages/ui/src/components/checkbox/Checkbox.vue | |||
defaultValue | boolean | "indeterminate" | undefined | undefined | The initial state in uncontrolled mode; it only applies when checked is not set. |
DetailsDeclared typeboolean | "indeterminate" | undefined Literal values
Default value details
Sourcepackages/ui/src/components/checkbox/Checkbox.vue | |||
disabled | boolean | undefined | false | Disables checkbox interaction and passes the disabled state to the underlying Reka UI primitive. |
DetailsDeclared typeboolean | undefined Literal values
Default value details
Sourcepackages/ui/src/components/checkbox/Checkbox.vue | |||
variant | "accent" | "danger" | "default" | "primary" | "secondary" | undefined | "default" | Selects the checkbox color style variant. |
DetailsDeclared typeNonNullable<"default" | "primary" | "secondary" | "danger" | "accent" | null | undefined> | undefined Literal values
Default value details
Sourcepackages/ui/src/components/checkbox/Checkbox.vue | |||
size | "default" | "lg" | "sm" | undefined | "default" | Sets the size of the checkbox and its state icon. |
DetailsDeclared typeNonNullable<"default" | "lg" | "sm" | null | undefined> | undefined Literal values
Default value details
Sourcepackages/ui/src/components/checkbox/Checkbox.vue | |||
ariaLabel | string | undefined | undefined | The checkbox accessible name; localized default text is used when omitted. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/checkbox/Checkbox.vue | |||
name | string | undefined | undefined | The native form field name. When set, the checkbox value is submitted with its form. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/checkbox/Checkbox.vue | |||
valueNullable | AcceptableValue | undefined | undefined | The value submitted with the form. It is forwarded to the Reka UI root primitive, whose native default is on when omitted. |
DetailsDeclared typeAcceptableValue | undefined Literal values
Default value details
Sourcepackages/ui/src/components/checkbox/Checkbox.vue | |||
required | boolean | undefined | false | Sets the native form required state and passes it to the underlying primitive. |
DetailsDeclared typeboolean | undefined Literal values
Default value details
Sourcepackages/ui/src/components/checkbox/Checkbox.vue | |||
| Name | Signature or type | Description |
|---|---|---|
@update:checked | [value: boolean | "indeterminate"] | Emits the new boolean or indeterminate state when it changes; supports v-model:checked. |
DetailsDeclared type[value: boolean | "indeterminate"] Literal values
Sourcepackages/ui/src/components/checkbox/Checkbox.vue | ||
Accessibility
- Keyboard: Supports
Spacekey to toggle checked state - ARIA attributes: Checkbox provides
aria-labelvia locale by default. Falls back tot('checkbox.check')when not provided. Can be omitted when adjacent visible text already describes the purpose; otherwise, provide a more specific description viaariaLabel - Focus management: Uses
--brutal-ringtoken for visible focus ring
<script setup>
import { ref } from 'vue'
import { Checkbox, Label } from 'brutx-ui-vue'
const checked = ref(false)
</script>
<template>
<div class="flex items-center gap-3">
<Checkbox v-model:checked="checked" id="marketing" ariaLabel="Receive marketing emails" />
<Label for="marketing">Receive marketing emails</Label>
</div>
</template>