Skip to content

Checkbox ​

Features:

  • Color
  • Size
  • Label
  • Single value binding (boolean)
  • Multiple value binding (array)

Usage ​

vue
<script setup>
import { Checkbox } from 'gurunkit';
</script>

<template>
  <Checkbox label="Checkbox" />
</template>

Without Label ​

label is optional.

vue
<script setup>
import { Checkbox } from 'gurunkit';
</script>

<template>
  <Checkbox />
</template>

Color ​

Set checkbox color using color props. Supported values: primary, light, error, warning, success.

It's also supports dark mode, enable it by adding dark class to html tag.

vue
<script setup>
import { Checkbox } from 'gurunkit';
</script>

<template>
  <Checkbox color="primary" label="Primary" />
  <Checkbox color="warning" label="Warning" />
  <Checkbox color="error" label="Error" />
  <Checkbox color="light" label="Light" />
  <Checkbox color="success" label="Success" />
</template>

Size ​

Set checkbox size using size props. Supported values: sm, md, lg.

vue
<script setup>
import { Checkbox } from 'gurunkit';
</script>

<template>
  <Checkbox size="sm" label="Small" />
  <Checkbox size="md" label="Medium" />
  <Checkbox size="lg" label="Large" />
</template>

V-Model ​

Boolean Value ​

Bind a single boolean value using v-model.

vue
<script setup>
import { Checkbox } from 'gurunkit';
import { ref } from 'vue';

const agree = ref(true);
</script>

<template>
  <Checkbox label="Agree" v-model="agree" />
</template>

Agree: true

Array Value ​

Bind a multiple value (array) using v-model.

Specify each checkbox value using input-value props.

vue
<script setup>
import { Checkbox } from 'gurunkit';
import { ref } from 'vue';

const selected = ref(['javascript', 'php', 'cpp']);
</script>

<template>
  <Checkbox label="Javascript" input-value="javascript" v-model="selected" />
  <Checkbox label="PHP" input-value="php" v-model="selected" />
  <Checkbox label="CPP" input-value="cpp" v-model="selected" />
</template>

Selected: [ "javascript" ]

HTML Attributes and Events ​

HTML attributes and events are automatically inherited.

vue
<script setup>
import { Checkbox } from 'gurunkit';
import { ref } from 'vue';

const onCheck = () => alert('test');
</script>

<template>
  <Checkbox
    id="remember_me"
    name="remember_me"
    label="Remember Me"
    @change="onCheck"
  />
</template>

API ​

Props ​

NameTypeRequiredDefaultDescription
colorprimary, light, success, warning, error❌primaryCheckbox color
inputValuestring❌nullCheckbox input value
labelstring❌nullCheckbox label
sizesm, md, lg❌mdCheckbox size
All HTML attributes-❌-HTML attributes

Events ​

NameTypeDescription
All HTML events-HTML events

Model Value ​

NameTypeDescription
defaultstring or any[]Bind a boolean or array value

Released under the MIT License.