<BaseCheckbox /> · A simple checkbox component.
<template>
<BaseCheckboxGroup v-model="value">
<BaseCheckbox
label="Option 1"
value="Option 1"
/>
<BaseCheckbox
label="Option 2"
value="Option 2"
/>
<BaseCheckbox
value="Option 3"
label="Option 3"
/>
</BaseCheckboxGroup>
</template>
<script setup lang="ts">
const value = ref('Option 1')
</script>
The Group component is a container for the Checkbox components. The Checkbox component is a simple checkbox button.
<template>
<BaseCheckboxGroup>
<BaseCheckbox />
<BaseCheckbox />
<BaseCheckbox />
</BaseCheckboxGroup>
</template>
This component has props that you can use to modify its visual style.
| Model | Type |
|---|---|
model-value | AcceptableValue[]The controlled value of the checkbox. Can be binded with v-model. |
| Prop | Type |
|---|---|
itemsdefault: [] | BaseCheckboxProps[] |
default-valuedefault: - | AcceptableValue[]The value of the checkbox when it is initially rendered. Use when you do not need to control its value. |
roving-focusdefault: - | booleanWhen `false`, navigating through the items using arrow keys will be disabled. |
disableddefault: - | booleanWhen `true`, prevents the user from interacting with the checkboxes |
asdefault: - | AsTag | ComponentThe element or component this component should render as. Can be overwritten by `asChild`. |
as-childdefault: - | booleanChange the default rendered element for the one passed as a child, merging their props and behavior. Read our [Composition](https://www.reka-ui.com/docs/guides/composition) guide for more details. |
dirdefault: - | Direction_2The direction of navigation between items. |
orientationdefault: - | OrientationThe orientation of the group. Mainly so arrow navigation is done accordingly (left & right vs. up & down) |
loopdefault: - | booleanWhether keyboard navigation should loop around |
namedefault: - | stringThe name of the field. Submitted with its owning form as part of a name/value pair. |
requireddefault: - | booleanWhen `true`, indicates that the user must set the value before the owning form can be submitted. |
| Slot | Type |
|---|---|
#default | any |
| Model | Type |
|---|---|
model-value | boolean | "indeterminate" | nullThe controlled value of the checkbox. Can be binded with v-model. |
| Prop | Type |
|---|---|
labeldefault: - | stringThe label to display for the checkbox. |
variantdefault: "default" | "default" | "none" | "primary" | "dark"The variant of the checkbox. |
classesdefault: {} | { root?: string | string[]; icon?: string | string[]; indicator?: string | string[]; label?: string | string[]; labelWrapper?: string | string[]; }Optional classes to pass to the inner components. |
default-valuedefault: - | boolean | "indeterminate"The value of the checkbox when it is initially rendered. Use when you do not need to control its value. |
disableddefault: - | booleanWhen `true`, prevents the user from interacting with the checkbox |
valuedefault: - | AcceptableValueThe value given as data when submitted with a `name`. |
iddefault: - | stringId of the element |
as-childdefault: - | booleanChange the default rendered element for the one passed as a child, merging their props and behavior. Read our [Composition](https://www.reka-ui.com/docs/guides/composition) guide for more details. |
asdefault: - | AsTag | ComponentThe element or component this component should render as. Can be overwritten by `asChild`. |
namedefault: - | stringThe name of the field. Submitted with its owning form as part of a name/value pair. |
requireddefault: - | booleanWhen `true`, indicates that the user must set the value before the owning form can be submitted. |
| Slot | Type |
|---|---|
#default | any |
Use the variant prop to change the color of the radio.
<template>
<BaseCheckbox
v-model="value"
label="Option 2"
variant="primary"
/>
</template>
<script setup lang="ts">
const value = ref(true)
</script>
Set the variant prop to none and use tailwind classes to customize the radio.
<template>
<BaseCheckbox
v-model="value"
label="Option 2"
variant="none"
class="bg-amber-500/10 dark:bg-amber-500/20 border-1 border-muted-300 dark:border-muted-700 text-amber-700 dark:text-amber-400"
/>
</template>
<script setup lang="ts">
const value = ref(true)
</script>
Use BaseCheckboxGroup to create a group of checkboxes. Bond it to a v-model to control the selected values.
<template>
<BaseCheckboxGroup v-model="multipleValue" class="p-4 grid grid-cols-2 gap-6 md:max-w-lg md:grid-cols-4">
<BaseCheckbox
name="multiple-demo-1"
label="Option 1"
value="Option 1"
/>
<BaseCheckbox
name="multiple-demo-2"
label="Option 2"
value="Option 2"
/>
<BaseCheckbox
name="multiple-demo-3"
label="Option 3"
value="Option 3"
/>
<BaseCheckbox
name="multiple-demo-4"
label="Option 4"
value="Option 4"
/>
</BaseCheckboxGroup>
</template>
<script setup lang="ts">
const value = ref(true)
</script>
Use the disabled prop to disable the checkbox.
<template>
<BaseCheckbox
v-model="value"
label="Option 2"
disabled
/>
</template>
<script setup lang="ts">
const value = ref(true)
</script>