Skip to content

Checkbox

Checkboxes allow the user to select one or more items from a set.

Basic Usage

You can also add a label to the checkbox by using the label attribute.

Value: false

vue
<template>
  <SprCheckbox v-model="checkbox" label="Checkbox Label" />
</template>

<script lang="ts" setup>
import { ref } from 'vue';

const checkbox = ref(false);
</script>

Adding Description

You can add a description to the checkbox by using the description attribute.

vue
<template>
  <SprCheckbox
    v-model="checkbox"
    label="Checkbox Label"
    description="Lorem ipsum dolor sit amet, consectetur adipiscing elit."
  />
</template>

<script lang="ts" setup>
import { ref } from 'vue';

const checkbox = ref(false);
</script>

Checked

Checkboxes can be set to checked by the use of v-model or checked props.

Using v-model:
vue
<template>
  <SprCheckbox v-model="checkbox" label="Checkbox Label" />
</template>

<script lang="ts" setup>
import { ref } from 'vue';

const checkbox = ref(true);
</script>
Using checked props:
vue
<template>
  <SprCheckbox label="Checkbox Label" checked />
</template>

<script lang="ts" setup>
import { ref } from 'vue';

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

Disabled

Add disabled attribute to make the checkbox disabled.

vue
<template>
  <SprCheckbox v-model="checkbox" label="Checkbox Label" disabled />
</template>

<script lang="ts" setup>
import { ref } from 'vue';

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

Indeterminate

Add indeterminate attribute to make the icon of the checkbox a minus sign.

vue
<template>
  <SprCheckbox v-model="checkbox" label="Checkbox Label" indeterminate />
  <SprCheckbox v-model="checkbox2" label="Checkbox Label" indeterminate disabled/>
</template>

<script lang="ts" setup>
import { ref } from 'vue';

const checkbox = ref(true);
const checkbox2 = ref(true);
</script>

API Reference

NameDescriptionTypeDefault
idID of the `checkbox` elementstring-
labelLabel of a checkboxstring-
descriptionDescription of a checkbox. Located at the bottom of label.string-
disabledif `true`, the component is disabledbooleanfalse
indeterminateif `true`, the component icon for checked state becomes `-`booleanfalse
borderedAdd border to the componentBooleanfalse
fullWidthDefines if component is fit-content or full widthBooleanfalse