v2.1.8
/
  • Get Started
  • Components
  • Composables
  • Typography
  • GitHub
  • Layout
  • App
  • Container
  • Error
  • SidebarLayout
  • Element
  • Advice
  • Alert
  • Avatar
  • AvatarGroup
  • Badge
  • Banner
  • Button
  • Calendar
  • Card
  • Chip
  • Collapsible
  • Countdown
  • FieldGroup
  • Kbd
  • Progress
  • Separator
  • Skeleton
  • Form
  • Checkbox
  • CheckboxGroup
  • ColorPicker
  • FileUpload
  • Form
  • FormField
  • Input
  • InputDate
  • InputMenu
  • InputNumber
  • InputTags
  • InputTime
  • PinInput
  • RadioGroup
  • Range
  • Select
  • SelectMenu
  • Switch
  • Textarea
  • Data
  • Accordion
  • DescriptionList
  • Empty
  • Table
  • TableWrapper
  • Timeline
  • User
  • Navigation
  • Breadcrumb
  • CommandPalette
  • Link
  • NavigationMenu
  • Pagination
  • Stepper
  • Tabs
  • Overlay
  • ContextMenu
  • DropdownMenu
  • Modal
  • Popover
  • Slideover
  • Toast
  • Tooltip
  • Page
  • PageCard
  • PageColumns
  • PageGrid
  • PageLinks
  • PageList
  • Dashboard
  • DashboardGroup
  • DashboardSearch
  • DashboardSearchButton
  • AI Chat
  • soonChatMessage
  • soonChatMessages
  • soonChatPalette
  • soonChatPrompt
  • soonChatPromptSubmit
  • Content
  • ContentSearch
  • ContentSearchButton
  • ContentSurround
  • ContentToc
  • Color Mode
  • ColorModeAvatar
  • ColorModeButton
  • ColorModeImage
  • ColorModeSelect
  • ColorModeSwitch
  • i18n
  • LocaleSelect
  • b24icons
  • b24jssdk
Use our Nuxt starter
v2.1.8
  • Docs
  • Components
  • Composables
  • Typography

CheckboxGroup

Multi-select checklist using button controls.
GitHub
Demo
Nuxt UI
CheckboxGroupCheckboxGroup

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.

{
  "wait": "Loading client-side content..."
}

Items

Use the items prop as an array of strings or numbers:

{
  "wait": "Loading client-side content..."
}

You can also pass an array of objects with the following properties:

  • label?: string
  • description?: string
  • value?: string
  • disabled?: boolean
  • class?: any
  • b24ui?: { item?: ClassNameValue, container?: ClassNameValue, base?: ClassNameValue, 'indicator'?: ClassNameValue, wrapper?: ClassNameValue, label?: ClassNameValue, description?: ClassNameValue }

This is the first option.

This is the second option.

This is the third option.

{
  "wait": "Loading client-side content..."
}
When using objects, you need to reference the 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.

This is the first option.

This is the second option.

This is the third option.

{
  "wait": "Loading client-side content..."
}

Legend

Use the legend prop to set the legend of the CheckboxGroup.

Theme
{
  "wait": "Loading client-side content..."
}

Color

Use the color prop to change the color of the CheckboxGroup.

{
  "wait": "Loading client-side content..."
}

Variant

Use the variant prop to change the variant of the CheckboxGroup.

{
  "wait": "Loading client-side content..."
}

Size

Use the size prop to change the size of the CheckboxGroup.

{
  "wait": "Loading client-side content..."
}

Orientation

Use the orientation prop to change the orientation of the CheckboxGroup. Defaults to vertical.

{
  "wait": "Loading client-side content..."
}

Indicator

Use the indicator prop to change the position or hide the indicator. Defaults to start.

{
  "wait": "Loading client-side content..."
}

Disabled

Use the disabled prop to disable the CheckboxGroup.

{
  "wait": "Loading client-side content..."
}

API

Props

Prop Default Type
as'div'any

The element or component this component should render as.

legend string
valueKey'value' string | number

When items is an array of objects, select the field to use as the value.

labelKey'label' string | number

When items is an array of objects, select the field to use as the label.

descriptionKey'description' string | number

When items is an array of objects, select the field to use as the description.

items CheckboxGroupItem[]
  • label?: string
  • description?: string
  • disabled?: boolean
  • value?: string
  • class?: any
  • b24ui?: (Pick<{ root?: ClassNameValue; fieldset?: ClassNameValue; legend?: ClassNameValue; item?: ClassNameValue; }, "item"> & Omit<{ root?: ClassNameValue; base?: ClassNameValue; indicator?: ClassNameValue; container?: ClassNameValue; icon?: ClassNameValue; wrapper?: ClassNameValue; label?: ClassNameValue; description?: ClassNameValue; }, "root">)
modelValue any[]

The controlled value of the CheckboxGroup. Can be bind as v-model.

defaultValue any[]

The value of the CheckboxGroup when initially rendered. Use when you do not need to control the state of the CheckboxGroup.

size'md' "xs" | "sm" | "md" | "lg"
variant'list' "card" | "list" | "table"
orientation'vertical' "horizontal" | "vertical"

The orientation the checkbox buttons are laid out.

disabledboolean

When true, prevents the user from interacting with the checkboxes

loopfalseboolean

Whether keyboard navigation should loop around

name string

The name of the field. Submitted with its owning form as part of a name/value pair.

requiredboolean

When true, indicates that the user must set the value before the owning form can be submitted.

color'air-primary'"air-primary" | "air-primary-success" | "air-primary-alert" | "air-primary-warning" | "air-primary-copilot"
indicator'start' "start" | "end" | "hidden"

Position of the indicator.

b24ui { root?: ClassNameValue; fieldset?: ClassNameValue; legend?: ClassNameValue; item?: ClassNameValue; } & { root?: ClassNameValue; base?: ClassNameValue; indicator?: ClassNameValue; container?: ClassNameValue; icon?: ClassNameValue; wrapper?: ClassNameValue; label?: ClassNameValue; description?: ClassNameValue; }
  • root?: ClassNameValue
  • fieldset?: ClassNameValue
  • legend?: ClassNameValue
  • item?: ClassNameValue
  • base?: ClassNameValue
  • indicator?: ClassNameValue
  • container?: ClassNameValue
  • icon?: ClassNameValue
  • wrapper?: ClassNameValue
  • label?: ClassNameValue
  • description?: ClassNameValue

Slots

Slot Type
legend{}
label{ item: CheckboxGroupItem & { id: string; }; }
description{ item: CheckboxGroupItem & { id: string; }; }

Emits

Event Type
update:modelValue[value: CheckboxGroupItem[]]
change[event: Event]

Theme

app.config.ts
export default defineAppConfig({
  b24ui: {
    checkboxGroup: {
      slots: {
        root: 'relative',
        fieldset: 'flex gap-x-2',
        legend: 'mb-1.5 block text-(--b24ui-typography-label-color)',
        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-[8px]',
            legend: 'text-(length:--ui-font-size-sm)'
          },
          lg: {
            fieldset: 'gap-x-[16px] gap-y-[8px]',
            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'
      }
    }
  }
})
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import bitrix24UIPluginVite from '@bitrix24/b24ui-nuxt/vite'

export default defineConfig({
  plugins: [
    vue(),
    bitrix24UIPluginVite({
      b24ui: {
        checkboxGroup: {
          slots: {
            root: 'relative',
            fieldset: 'flex gap-x-2',
            legend: 'mb-1.5 block text-(--b24ui-typography-label-color)',
            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-[8px]',
                legend: 'text-(length:--ui-font-size-sm)'
              },
              lg: {
                fieldset: 'gap-x-[16px] gap-y-[8px]',
                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'
          }
        }
      }
    })
  ]
})

Checkbox

A toggle input for marking as checked or unchecked.

ColorPicker

A color picker component.

On this page

  • Usage
    • Items
    • Value Key
    • Legend
    • Color
    • Variant
    • Size
    • Orientation
    • Indicator
    • Disabled
  • API
    • Props
    • Slots
    • Emits
  • Theme
Releases
Published under MIT License.

Copyright © 2024-present Bitrix24