Usage
Use the v-model directive to control the value of the CheckboxGroup or the default-value prop to set the initial value when you do not need to control its state.
<script setup lang="ts">
const items = ref(['System', 'Light', 'Dark'])
const value = ref(['System'])
</script>
<template>
<B24CheckboxGroup v-model="value" :items="items" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
const items = ref(['System', 'Light', 'Dark'])
const value = ref(['System'])
</script>
<template>
<B24CheckboxGroup v-model="value" :items="items" />
</template>
Items
Use the items prop as an array of strings or numbers:
<script setup lang="ts">
const items = ref(['System', 'Light', 'Dark'])
const value = ref(['System'])
</script>
<template>
<B24CheckboxGroup v-model="value" :items="items" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
const items = ref(['System', 'Light', 'Dark'])
const value = ref(['System'])
</script>
<template>
<B24CheckboxGroup v-model="value" :items="items" />
</template>
You can also pass an array of objects with the following properties:
label?: stringdescription?: stringvalue?: stringdisabled?: booleanicon?: IconComponentclass?: anyb24ui?: { item?: ClassNameValue, container?: ClassNameValue, base?: ClassNameValue, 'indicator'?: ClassNameValue, wrapper?: ClassNameValue, label?: ClassNameValue, description?: ClassNameValue }
<script setup lang="ts">
import type { CheckboxGroupItem } from '@bitrix24/b24ui-nuxt'
const items = ref<CheckboxGroupItem[]>([
{
label: 'System',
description: 'This is the first option.',
value: 'system'
},
{
label: 'Light',
description: 'This is the second option.',
value: 'light'
},
{
label: 'Dark',
description: 'This is the third option.',
value: 'dark'
}
])
const value = ref([
'system'
])
</script>
<template>
<B24CheckboxGroup v-model="value" :items="items" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { CheckboxGroupItem } from '@bitrix24/b24ui-nuxt'
const items = ref<CheckboxGroupItem[]>([
{
label: 'System',
description: 'This is the first option.',
value: 'system'
},
{
label: 'Light',
description: 'This is the second option.',
value: 'light'
},
{
label: 'Dark',
description: 'This is the third option.',
value: 'dark'
}
])
const value = ref([
'system'
])
</script>
<template>
<B24CheckboxGroup v-model="value" :items="items" />
</template>
value property of the object in the v-model directive or the default-value prop.Value Key
You can change the property that is used to set the value by using the value-key prop. Defaults to value.
<script setup lang="ts">
import type { CheckboxGroupItem } from '@bitrix24/b24ui-nuxt'
const items = ref<CheckboxGroupItem[]>([
{
label: 'System',
description: 'This is the first option.',
id: 'system'
},
{
label: 'Light',
description: 'This is the second option.',
id: 'light'
},
{
label: 'Dark',
description: 'This is the third option.',
id: 'dark'
}
])
const value = ref([
'light'
])
</script>
<template>
<B24CheckboxGroup v-model="value" value-key="id" :items="items" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { CheckboxGroupItem } from '@bitrix24/b24ui-nuxt'
const items = ref<CheckboxGroupItem[]>([
{
label: 'System',
description: 'This is the first option.',
id: 'system'
},
{
label: 'Light',
description: 'This is the second option.',
id: 'light'
},
{
label: 'Dark',
description: 'This is the third option.',
id: 'dark'
}
])
const value = ref([
'light'
])
</script>
<template>
<B24CheckboxGroup v-model="value" value-key="id" :items="items" />
</template>
Legend
Use the legend prop to set the legend of the CheckboxGroup.
<script setup lang="ts">
const items = ref(['System', 'Light', 'Dark'])
</script>
<template>
<B24CheckboxGroup
legend="Theme"
:default-value="{
'0': 'System'
}"
:items="items"
/>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const items = ref(['System', 'Light', 'Dark'])
</script>
<template>
<B24CheckboxGroup
legend="Theme"
:default-value="{
'0': 'System'
}"
:items="items"
/>
</template>
Color
Use the color prop to change the color of the CheckboxGroup.
<script setup lang="ts">
const items = ref(['System', 'Light', 'Dark'])
</script>
<template>
<B24CheckboxGroup
color="air-primary-copilot"
:default-value="{
'0': 'System'
}"
:items="items"
/>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const items = ref(['System', 'Light', 'Dark'])
</script>
<template>
<B24CheckboxGroup
color="air-primary-copilot"
:default-value="{
'0': 'System'
}"
:items="items"
/>
</template>
Variant
Use the variant prop to change the variant of the CheckboxGroup.
<script setup lang="ts">
const items = ref(['System', 'Light', 'Dark'])
</script>
<template>
<B24CheckboxGroup
color="air-primary-copilot"
variant="card"
:default-value="{
'0': 'System'
}"
:items="items"
/>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const items = ref(['System', 'Light', 'Dark'])
</script>
<template>
<B24CheckboxGroup
color="air-primary-copilot"
variant="card"
:default-value="{
'0': 'System'
}"
:items="items"
/>
</template>
Size
Use the size prop to change the size of the CheckboxGroup.
<script setup lang="ts">
const items = ref(['System', 'Light', 'Dark'])
</script>
<template>
<B24CheckboxGroup
size="lg"
variant="list"
:default-value="{
'0': 'System'
}"
:items="items"
/>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const items = ref(['System', 'Light', 'Dark'])
</script>
<template>
<B24CheckboxGroup
size="lg"
variant="list"
:default-value="{
'0': 'System'
}"
:items="items"
/>
</template>
Orientation
Use the orientation prop to change the orientation of the CheckboxGroup. Defaults to vertical.
<script setup lang="ts">
const items = ref(['System', 'Light', 'Dark'])
</script>
<template>
<B24CheckboxGroup
orientation="horizontal"
variant="list"
:default-value="{
'0': 'System'
}"
:items="items"
/>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const items = ref(['System', 'Light', 'Dark'])
</script>
<template>
<B24CheckboxGroup
orientation="horizontal"
variant="list"
:default-value="{
'0': 'System'
}"
:items="items"
/>
</template>
Indicator
Use the indicator prop to change the position or hide the indicator. Defaults to start.
icon replaces the check mark while the indicator is visible, and is displayed above the label when it is hidden.<script setup lang="ts">
const items = ref(['System', 'Light', 'Dark'])
</script>
<template>
<B24CheckboxGroup
indicator="end"
variant="card"
:default-value="{
'0': 'System'
}"
:items="items"
/>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const items = ref(['System', 'Light', 'Dark'])
</script>
<template>
<B24CheckboxGroup
indicator="end"
variant="card"
:default-value="{
'0': 'System'
}"
:items="items"
/>
</template>
Disabled
Use the disabled prop to disable the CheckboxGroup.
<script setup lang="ts">
const items = ref(['System', 'Light', 'Dark'])
</script>
<template>
<B24CheckboxGroup
disabled
variant="list"
:default-value="{
'0': 'System'
}"
:items="items"
/>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const items = ref(['System', 'Light', 'Dark'])
</script>
<template>
<B24CheckboxGroup
disabled
variant="list"
:default-value="{
'0': 'System'
}"
:items="items"
/>
</template>
Examples
Settings layout
Use the card variant together with the #label slot to render a settings-style picker where each option has a title, description, a "Learn more" link and a preview image. The label slot renders inside a <span>, so any phrasing-content layout (flex, link, image) works.
Build a rich checkbox-card settings picker (preview + description + link).
Build a multi-toggle settings picker as B24CheckboxGroup with variant="card". Each option renders a title, a multi-line description, an inline "Learn more" link and a preview image on the right side, laid out via the #label slot. Several options can be enabled at once — v-model binds to an array.
Before generating the code, ask me for the missing details — do not guess:
- How many capabilities there are and what their
value/title/ description text should be - The URL behind each "Learn more" link (and whether all options share one or each has its own)
- Where the preview asset comes from: real image,
<Placeholder>while artwork is in flight, or omit entirely - Whether selection must be persisted (
v-modeltarget — localref<string[]>, Pinia store, query param, server) - Which
size(sm/md/lg) andcolortoken fit the surrounding page - Whether the picker is inside a
B24Form(then it should be wrapped inB24FormFieldwith a label) - Whether any combinations are mutually exclusive — if yes, that logic must live in the parent (e.g. a
watchthat prunes incompatible values), not in the markup
Requirements once details are confirmed:
- Declare a local
interfacefor the item shape (value,title,text,href, optionalpreview) and type the array with it — do NOT useCheckboxGroupItem[](that widens user fields toany) - Inside the
#labelslot use<span>wrappers only (no<div>/<p>— the slot is rendered as<span>for thecardvariant) - Apply semantic utilities (
text-description,text-(length:--ui-font-size-md), …) — never raw Tailwind palette colors - Hide the preview below the
smbreakpoint (hidden sm:flex) - Add
@click.stopto the inlineB24Linkso the link doesn't toggle the checkbox - If
item.hrefmay come from an untrusted source, validate it (rejectjavascript:/data:/ open-redirect URLs) before binding
@click.stop to it.B24PageCardGroup instead.API
Props
Slots
Emits
Theme
export default {
slots: {
root: 'relative',
fieldset: 'flex gap-x-2',
legend: 'mb-1.5 block text-label',
item: ''
},
variants: {
orientation: {
horizontal: {
fieldset: 'flex-row'
},
vertical: {
fieldset: 'flex-col'
}
},
color: {
'air-primary': {
item: 'style-filled'
},
'air-primary-success': {
item: 'style-filled-success'
},
'air-primary-alert': {
item: 'style-filled-alert'
},
'air-primary-copilot': {
item: 'style-filled-copilot'
},
'air-primary-warning': {
item: 'style-filled-warning'
},
default: {
item: 'style-old-default'
},
danger: {
item: 'style-old-danger'
},
success: {
item: 'style-old-success'
},
warning: {
item: 'style-old-warning'
},
primary: {
item: 'style-old-primary'
},
secondary: {
item: 'style-old-secondary'
},
collab: {
item: 'style-old-collab'
},
ai: {
item: 'style-old-ai'
}
},
variant: {
list: {},
card: {
item: 'cursor-pointer items-start border border-(--ui-color-design-outline-na-stroke) bg-(--ui-color-design-outline-na-bg) has-data-[state=checked]:border-(--b24ui-border-color)'
},
table: {
item: 'cursor-pointer border border-(--ui-color-design-outline-na-stroke) bg-(--ui-color-design-outline-na-bg) has-data-[state=checked]:bg-(--b24ui-background)/24 has-data-[state=checked]:border-(--b24ui-border-color) has-data-[state=checked]:text-(--b24ui-color) has-data-[state=checked]:z-[1]'
}
},
size: {
xs: {
fieldset: 'gap-x-[12px] gap-y-[4px]',
legend: 'text-(length:--ui-font-size-xs)'
},
sm: {
fieldset: 'gap-x-[14px] gap-y-[6px]',
legend: 'text-(length:--ui-font-size-xs)'
},
md: {
fieldset: 'gap-x-[16px] gap-y-2',
legend: 'text-(length:--ui-font-size-sm)'
},
lg: {
fieldset: 'gap-x-[16px] gap-y-2',
legend: 'text-(length:--ui-font-size-sm)'
}
},
disabled: {
true: {}
},
required: {
true: {
label: "after:content-['*'] after:ms-0.5 after:text-(--ui-color-accent-main-alert)"
}
}
},
compoundVariants: [
{
size: 'xs',
variant: 'card',
class: {
item: 'px-[13px] py-[7px] rounded-(--ui-border-radius-xs)'
}
},
{
size: 'sm',
variant: 'card',
class: {
item: 'px-[13px] py-[9px] rounded-(--ui-border-radius-sm)'
}
},
{
size: 'md',
variant: 'card',
class: {
item: 'px-[17px] py-[10px] rounded-(--ui-border-radius-md)'
}
},
{
size: 'lg',
variant: 'card',
class: {
item: 'px-[23px] py-[12px] rounded-(--ui-border-radius-md)'
}
},
{
size: 'xs',
variant: 'table',
class: {
item: 'px-[13px] py-[7px]'
}
},
{
size: 'sm',
variant: 'table',
class: {
item: 'px-[13px] py-[9px]'
}
},
{
size: 'md',
variant: 'table',
class: {
item: 'px-[17px] py-[10px]'
}
},
{
size: 'lg',
variant: 'table',
class: {
item: 'px-[23px] py-[12px]'
}
},
{
size: 'xs',
variant: 'table',
orientation: 'horizontal',
class: {
item: 'first-of-type:rounded-s-(--ui-border-radius-xs) last-of-type:rounded-e-(--ui-border-radius-xs)',
fieldset: 'gap-0 -space-x-px'
}
},
{
size: 'xs',
variant: 'table',
orientation: 'vertical',
class: {
item: 'first-of-type:rounded-t-(--ui-border-radius-xs) last-of-type:rounded-b-(--ui-border-radius-xs)',
fieldset: 'gap-0 -space-y-px'
}
},
{
size: 'sm',
variant: 'table',
orientation: 'horizontal',
class: {
item: 'first-of-type:rounded-s-(--ui-border-radius-sm) last-of-type:rounded-e-(--ui-border-radius-sm)',
fieldset: 'gap-0 -space-x-px'
}
},
{
size: 'sm',
variant: 'table',
orientation: 'vertical',
class: {
item: 'first-of-type:rounded-t-(--ui-border-radius-sm) last-of-type:rounded-b-(--ui-border-radius-sm)',
fieldset: 'gap-0 -space-y-px'
}
},
{
size: [
'lg',
'md'
],
variant: 'table',
orientation: 'horizontal',
class: {
item: 'first-of-type:rounded-s-(--ui-border-radius-md) last-of-type:rounded-e-(--ui-border-radius-md)',
fieldset: 'gap-0 -space-x-px'
}
},
{
size: [
'lg',
'md'
],
variant: 'table',
orientation: 'vertical',
class: {
item: 'first-of-type:rounded-t-(--ui-border-radius-md) last-of-type:rounded-b-(--ui-border-radius-md)',
fieldset: 'gap-0 -space-y-px'
}
},
{
variant: 'table',
disabled: true,
class: {
item: 'cursor-not-allowed'
}
}
],
defaultVariants: {
size: 'md',
variant: 'list',
color: 'air-primary'
}
}