np-checkbox Checkbox Group

A wrapper around n-checkbox-group that adds async option support.

Basic Usage

Specify options through options, and bind the value with v-model.

浏览器不支持,请手动复制 basic.en.vue

Async Options

The options prop supports an async function, e.g. for fetching dictionaries from a backend API.

浏览器不支持,请手动复制 async.en.vue

Async Computed Options

The options prop supports an async computed function, e.g. for fetching different dictionaries from different APIs based on the type.

浏览器不支持,请手动复制 computed.en.vue

Custom Field Names

Usually options are fetched from a backend, and the data structure is not always {label, value}. You can use keys to specify option field names.

浏览器不支持,请手动复制 keys.en.vue

Change Event

Get the value change via the change event.

浏览器不支持,请手动复制 change.en.vue

Component Configuration

Props

PropDescriptionTypeDefault
v-modelSelected valuesCheckboxGroupValue[]-
optionsOptionsAsyncValue<CheckboxOption[]>-
keysCustom field names{label: string, value: string}{ label: 'label', value: 'value' }
loadingDelayLoading delay in ms, effective when options is asyncnumber250
propsTCheckboxGroup propsTCheckboxGroup Propsopen in new window-
onChangeChange event(value: T, context: CheckboxGroupChangeContext) => void-

Events

EventDescriptionCallback
changeChange event(value: T, context: CheckboxGroupChangeContext) => void

Types

The component exports the following type definitions:

import type { NpCheckboxProps } from 'naive-plus'