Skip to content

GkCheckbox

Native <input type="checkbox"> with tokenized focus styles, wrapped in an inline-flex container so it aligns with adjacent labels. Pair with a visible <label> or pass ariaLabel.

When to use

Use for binary choices and “select all” controls where each option can be independently toggled.

Live demo

API

Props

PropTypeDefaultDescription
modelValuebooleanrequiredChecked state (v-model)
idstringOverrides injected field id
namestringForm name
valuestringNative value attribute (e.g. for named groups)
disabledbooleanfalseDisabled
readonlybooleanfalsePrevents toggling; uses aria-readonly and reverts change (native readonly is not used on checkboxes)
indeterminatebooleanfalseSets the native indeterminate state (separate from checked)
ariaLabelstringRequired when there is no visible label

Root class applies to the outer wrapper; other attributes are forwarded to the <input>.

Events

EventPayloadDescription
update:modelValuebooleanEmitted when the checked state changes
update:focusedbooleantrue on focus, false on blur

Expose

NameTypeDescription
inputHTMLInputElementThe native checkbox element

Examples

Basic

vue
<script setup lang="ts">
import { GkCheckbox } from 'god-kit/vue'
import { ref } from 'vue'
const ok = ref(false)
</script>

<template>
  <label>
    <GkCheckbox v-model="ok" />
    Accept
  </label>
</template>

Advanced

Indeterminate (e.g. “select all”)

Control indeterminate from the parent; when the user activates the checkbox, the browser clears indeterminate—update your state accordingly.

vue
<GkCheckbox v-model="allSelected" :indeterminate="someSelected" />

Edge case

vue
<label>
  <GkCheckbox v-model="approved" readonly aria-label="Readonly approval status" />
  Approved (readonly)
</label>

Accessibility notes

  • Provide visible label text or ariaLabel so each checkbox has a clear accessible name.
  • Use indeterminate only to communicate partial selection state, not as a third boolean value.

Released under the MIT License.