Skip to content
LIBRARYFormsUpdated

MultiSelect ​

Several choices. One place.

Added in alpha.7

Available in Mavis 0.1.0-alpha.7.

Web preview
Open example ↗
vue
<m-multi-select v-model="extras" :options="options" label="Extras" :maxSelected="2" />

Local search in a Sheet on both renderers. Every selected value must exist in options; filtering keeps selections. Remote pagination and virtualization are outside this control. Update options and selection consistently.

PropertyTypeDefaultDescription
modelValue / v-modelreadonly ChoiceValue[][]Unique values controlled by the app.
optionsreadonly ChoiceOption[]requiredLocal options with value, label and optional disabled state.
labelstringrequiredVisible label and Sheet title.
maxSelectednumber—Positive selection limit.
searchLabel / closeLabel / removeLabelstringSearch options / Done / RemoveAction labels supplied by the app.

A newly chosen value pops in as a chip where it lands. Removing one stays immediate in your model: the chip leaves the tree at once while a static copy shrinks and fades and its neighbours close the gap, including the last one. Values present on the first render do not animate, and reduced motion skips the arrival and the exit.

vue
<script setup lang="ts">
import { computed, ref } from 'vue'
import type { ChoiceValue } from '@getcortexlabs/mavis-core'
import { useCatalogLocale } from '../locale'
const props = defineProps<{ lang?: 'en' | 'pt' }>()
const { locale } = useCatalogLocale(() => props.lang)
const pt = computed(() => (props.lang ?? locale.value) === 'pt')
const selected = ref<ChoiceValue[]>(['frame'])
const options = computed(() => [
  { value: 'frame', label: pt.value ? 'Moldura' : 'Frame' },
  { value: 'gift', label: pt.value ? 'Embalagem de presente' : 'Gift wrapping' },
  { value: 'note', label: pt.value ? 'Cartão escrito à mão' : 'Handwritten note' },
  { value: 'signed', label: pt.value ? 'Edição assinada' : 'Signed edition', disabled: true },
])
</script>
<template>
  <m-column gap="md">
    <m-multi-select
      v-model="selected"
      :options="options"
      :maxSelected="2"
      :label="pt ? 'Extras' : 'Extras'"
      :searchLabel="pt ? 'Buscar extras' : 'Search extras'"
      :closeLabel="pt ? 'Concluir' : 'Done'"
      :removeLabel="pt ? 'Remover' : 'Remove'"
      :emptyLabel="pt ? 'Nenhuma opção encontrada' : 'No matching options'"
      :placeholder="pt ? 'Escolher extras' : 'Choose extras'"
    />
    <m-text tone="muted" variant="caption">{{
      pt
        ? 'Escolha até dois detalhes para deixar sua edição especial.'
        : 'Choose up to two details to make your edition special.'
    }}</m-text>
  </m-column>
</template>

The helper below the selection can give way to an error without moving the chips in one jump. Assistive technology receives the current description as soon as the error changes.

Desktop ​

On the desktop the options open in a list under the field with a search field on top, and its arrows and Return act on the list. Chosen values stay as chips under the field, each with its own remove button; see Desktop components.

Components for NativeScript and Web. Starting with Vue.