---
title: "MazChecklist"
description: "MazChecklist is a standalone component that allows creating a checklist with integrated search functionality. It provides a flexible and customizable user interface for selecting multiple items from a list of options. The component supports real-time search, color customization, and displays messages when no results are found."
package: "maz-ui"
url: "https://maz-ui.com/components/maz-checklist"
---

# MazChecklist

> MazChecklist is a standalone component that allows creating a checklist with integrated search functionality. It provides a flexible and customizable user interface for selecting multiple items from a list of options. The component supports real-time search, color customization, and displays messages when no results are found.

- Package: `maz-ui`
- Import: `import MazChecklist from 'maz-ui/components/MazChecklist'`
- Nuxt: auto-imported by `@maz-ui/nuxt`, no import needed in a Nuxt app
- Web: https://maz-ui.com/components/maz-checklist

> Before use it, you should install the MazUi plugin in your project, follow instructions in [Getting Started](../guide/getting-started.md)

**Tip:**

This component can be translated globally using the [MazUi](https://maz-ui.com/ecosystem/translations.md) plugin.

## Basic usage

```vue
<template>
  Selected languages: {{ languages || 'none' }}

  <br />

  <MazChecklist
    v-model="languages"
    v-model:query="query"
    title="Select your languages"
    :search="{
      enabled: true,
      placeholder: 'Search a language',
      debounce: 300,
      autoFocus: false,
      size: 'sm'
    }"
    :items="languagesOptions"
    class="h-80"
  >
    <template #item="{ item }">
      <div class="flex w-full items-center justify-between gap-2">
        <span class="capitalize">{{ item.label }}</span>
        <MazBadge color="theme" outlined>
          {{ item.value }}
        </MazBadge>
      </div>
    </template>
  </MazChecklist>
</template>

<script lang="ts" setup>
  import { ref } from 'vue'
  import MazChecklist from 'maz-ui/components/MazChecklist'
  import { useDisplayNames } from 'maz-ui/composables/useDisplayNames'

  const query = ref<string>()
  const languages = ref<string[]>()
  const languagesOptions = useDisplayNames('en-US').getAllDisplayNames({ type: 'language' }).value.map(({ code, name }) => ({
    label: name,
    value: code,
  }))
</script>
```

## Search

The search is a fuzzy search (the [fuzzySearch](https://maz-ui.com/ecosystem/utils/fuzzy-search.md) helper of `@maz-ui/utils`, loaded only with `search`): it finds the prefixes, the words in any order, the initials, the typos, whatever the accents and the case, in the label and the value of the items. The best matches come first.

`search-options.threshold` is the tolerance to typos: the minimal similarity (from 0 to 1) of a whole item with the query, for the items that do not contain it. `1` disables the typo tolerance (default `0.75`). The other `search-options` normalize the query given to a `search-function`.

## Custom search function

You can replace the default search function by providing a custom search function. Useful when you need to search by multiple fields, if you want to use a different search algorithm or if you want search into your database by fetching data from an API.

```vue
<template>
  Selected employees: {{ selectedEmployees || 'none' }}

  <br />

  <MazChecklist
    v-model="selectedEmployees"
    v-model:query="employeeQuery"
    title="Select team members"
    :search="{
      placeholder: 'Search by name, email, or department...',
      debounce: 200,
      block: true,
    }"
    :items="employees"
    :search-function="customEmployeeSearch"
    color="success"
    elevation
    class="max-h-96"
  >
    <template #item="{ item }">
      <div class="flex w-full items-center gap-4">
        <div class="flex h-12 w-12 flex-none items-center justify-center rounded-full bg-linear-to-br from-primary-500 to-secondary-500 text-white font-semibold text-lg">
          {{ item.initials }}
        </div>
        <div class="flex flex-1 flex-col gap-1">
          <div class="flex items-center gap-2">
            <span class="font-semibold text-normal">{{ item.label }}</span>
            <MazBadge :color="item.departmentColor" size="xs">
              {{ item.department }}
            </MazBadge>
          </div>
          <span class="text-muted text-sm">{{ item.email }}</span>
        </div>
        <div class="flex flex-none items-center gap-1">
          <MazIcon icon="/star.svg" class="text-warning-500" size="1rem" />
          <span class="text-sm font-medium">{{ item.rating }}</span>
        </div>
      </div>
    </template>
  </MazChecklist>
</template>

<script lang="ts" setup>
  import { ref } from 'vue'
  import MazChecklist from 'maz-ui/components/MazChecklist'

  const employeeQuery = ref<string>()
  const selectedEmployees = ref<string[]>()

  const employees = [
    {
      label: 'Sarah Johnson',
      value: 'sarah.johnson',
      email: 'sarah.johnson@company.com',
      department: 'Engineering',
      departmentColor: 'info',
      initials: 'SJ',
      rating: 4.9
    },
    {
      label: 'Michael Chen',
      value: 'michael.chen',
      email: 'michael.chen@company.com',
      department: 'Design',
      departmentColor: 'warning',
      initials: 'MC',
      rating: 4.7
    },
    {
      label: 'Emma Rodriguez',
      value: 'emma.rodriguez',
      email: 'emma.rodriguez@company.com',
      department: 'Marketing',
      departmentColor: 'success',
      initials: 'ER',
      rating: 4.8
    },
    {
      label: 'David Kim',
      value: 'david.kim',
      email: 'david.kim@company.com',
      department: 'Engineering',
      departmentColor: 'info',
      initials: 'DK',
      rating: 4.6
    },
    {
      label: 'Lisa Thompson',
      value: 'lisa.thompson',
      email: 'lisa.thompson@company.com',
      department: 'Product',
      departmentColor: 'contrast',
      initials: 'LT',
      rating: 4.9
    },
    {
      label: 'John Doe',
      value: 'john.doe',
      email: 'john.doe@company.com',
      department: 'Marketing',
      departmentColor: 'success',
      initials: 'JD',
      rating: 4.9
    },
    {
      label: 'Jane Smith',
      value: 'jane.smith',
      email: 'jane.smith@company.com',
      department: 'Engineering',
      departmentColor: 'info',
      initials: 'JS',
      rating: 4.9
    },
    {
      label: 'Jim Beam',
      value: 'jim.beam',
      email: 'jim.beam@company.com',
      department: 'Sales',
      departmentColor: 'destructive',
      initials: 'JB',
      rating: 4.9
    },
    {
      label: 'Jill Johnson',
      value: 'jill.johnson',
      email: 'jill.johnson@company.com',
      department: 'Marketing',
      departmentColor: 'success',
      initials: 'JJ',
      rating: 4.9
    },
  ]

  function customEmployeeSearch(query: string, items: typeof employees) {
    const searchTerm = query.toLowerCase().trim()

    if (!searchTerm) return items

    return items.filter(employee =>
      employee.label.toLowerCase().includes(searchTerm) ||
      employee.email.toLowerCase().includes(searchTerm) ||
      employee.department.toLowerCase().includes(searchTerm) ||
      employee.value.toLowerCase().includes(searchTerm)
    )
  }
</script>
```

## MazChecklist API

`import MazChecklist from 'maz-ui/components/MazChecklist'`

### Props

- `model-value` (`T[]`, `v-model`): The model value of the checklist (selected items).
- `query` (`string`, `v-model:query`): The query to filter the items (model).
- `items` (`O[]`): The list of items to display.
- `title` (`string`): The title of the checklist.
- `elevation` (`boolean`, default: `false`): Add elevation to the card.
- `search` (`boolean | MazInputProps<string>`, default: `{ enabled: false, debounce: 300, autoFocus: false }`): The search input options.
- `search-options` (`(NormalizeStringOptions & { threshold?: number | undefined; })`): The options to normalize the query given to `searchFunction`. `threshold` is the tolerance of the default search to typos: the minimal similarity (from 0 to 1) of a whole item with the query, `1` disables it (default 0.75). The default search always ignores the case and the accents.
- `search-function` (`((query: string, items: O[]) => O[] | undefined)`): Replace the default search function to provide a custom search function.
- `color` (`"primary" | "secondary" | "accent" | "info" | "success" | "warning" | "destructive" | "contrast" | "transparent"`, default: `"primary"`): The color of the checklist (card, checkbox and search input).
- `translations` (`{ noResultsFound?: string | undefined; searchInput?: { placeholder?: string | undefined; } | undefined; }`, default: `Translations from`): Translations of the checklist component.

### Events

- `@update:model-value` (payload: `value?: T[] | undefined`): Emitted when the model value change
- `@update:query` (payload: `value?: string | undefined`): Emitted when the query change

### Slots

- `#title`: use this slot to customize the title
- `#no-results`: use this slot to customize the no results area
- `#no-results-text`: use this slot to customize the no results message
- `#item`: use this slot to customize the item Bindings: `selectedValues: T[]`, `item: O`.
