Skip to content

Checkbox

Neobrutalist-styled checkbox built on reka-ui's CheckboxRoot primitive, with a check indicator.

Demo

Preview
默认
主要
危险
不确定状态(Minus 图标)
自定义 aria-label

Installation

pnpm dlx brutx-vue@latest add checkbox

Usage

vue
<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

VariantDescription
defaultDefault background, standard foreground
primaryPrimary (coral) background
secondarySecondary (mint) background
accentAccent (yellow) background
dangerDanger (red) background
vue
<template>
    <Checkbox variant="primary" />
</template>

Sizes

SizeDescription
smSmall
defaultDefault
lgLarge

With Label

vue
<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

vue
<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.

vue
<script setup>
import { Checkbox } from 'brutx-ui-vue'
</script>

<template>
    <Checkbox :checked="'indeterminate'" />
</template>

Props

PropTypeDefaultDescription
checkedboolean | 'indeterminate'Checked state
disabledbooleanfalseWhether disabled
variant'default' | 'primary' | 'secondary' | 'accent' | 'danger''default'Color variant
size'sm' | 'default' | 'lg''default'Size
ariaLabelstringLocale default (checkbox.check)Accessibility label
classstringCustom style class

Events

EventPayloadDescription
update:checkedboolean | 'indeterminate'Triggered when checked state changes, supports v-model:checked two-way binding

Accessibility

  • Keyboard: Supports Space key to toggle checked state
  • ARIA attributes: Checkbox provides aria-label via locale by default. Falls back to t('checkbox.check') when not provided. Can be omitted when adjacent visible text already describes the purpose; otherwise, provide a more specific description via ariaLabel
  • Focus management: Uses --brutal-ring token for visible focus ring
vue
<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>

Brute force builds.