---
title: MultiSelectFilter
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, FigmaEmbed, TokensTable, PropsTable } from '../../src/components'
import { MultiSelectFilter } from '@telus-uds/components-base'
import { MultiSelectFilter as BaseDocs } from 'docs/@telus-uds/components-base'
import NoStylisticVariants from '../../partials/_variants-none.mdx'
import AvailableOnBoth from '../../partials/_platform-considerations-both.mdx'

# MultiSelectFilter

<LibraryInfo />

```jsx live
<MultiSelectFilter
  label="colour"
  subtitle="Short and optional description to give customer more context"
  items={[
    { label: 'Red', id: 'red' },
    { label: 'Orange', id: 'orange' },
    { label: 'Yellow', id: 'yellow' },
    { label: 'Green', id: 'green' },
    { label: 'Blue', id: 'blue' },
    { label: 'Purple', id: 'purple' },
    { label: 'Black', id: 'black' },
    { label: 'White', id: 'white' },
    { label: 'Grey', id: 'grey' },
    { label: 'Brown', id: 'brown' },
    { label: 'Pink', id: 'pink' },
    { label: 'Cyan', id: 'cyan' }
  ]}
/>
```

## Introduction

`MultiSelectFilter` is built to show a number of options (`items`) with checkboxes in a `Modal`. User can check/uncheck the options and submit or clear. Submitted options will be stored in the component state. MultiSelectFilter uses the `open` and `selected` states of `ButtonDropdown` to manage the appearance. It has a custom pop-up layout in a `Modal` with specific breakpoints according to the number of options being shown. `Modal` will include two columns if the items are more than `rowLimit` which is `12` by default.

[Follow the appropriate instructions](importing-components) to add this component in to your app.

## Guidance

Use this component to display a filter of items on a page.

### Using JSX for `subtitle`

The `subtitle` prop can accept JSX, allowing for more complex content.

```jsx live
<MultiSelectFilter
  label="MultiSelectFilter"
  subtitle={
    <>
      <Typography variant={{ size: 'small', colour: 'secondary' }}>JSX subtitle example</Typography>
      <Tooltip content="This is a tooltip" position="below" inline activateOnHover />
    </>
  }
  items={[
    { label: 'Tag 1', id: 'tag1' },
    { label: 'Tag 2', id: 'tag2' },
    { label: 'Tag 3', id: 'tag3' },
    { label: 'Tag 4', id: 'tag4' },
    { label: 'Tag 5', id: 'tag5' }
  ]}
/>
```

### Accessibility

Elements in the content such as `CheckboxGroup`(s) in `Modal` will follow the natural tab order.

### Platform considerations

<AvailableOnBoth />

## Props

<PropsTable base={BaseDocs} />

### Use of `dismissWhenPressedOutside`

:::warning
Note: `dismissWhenPressedOutside` is deprecated and will be removed in the next major version. Consider that this behavior will be enabled by default.
:::

In this example, the `dismissWhenPressedOutside` prop is set to `true`, which means the modal will close if the user taps or clicks outside of it. This can improve the user experience by providing an easy way to dismiss the filter without explicitly clicking a close button.

```jsx live
<MultiSelectFilter
  label="Categories"
  subtitle="Select relevant categories"
  items={[
    { label: 'Electronics', id: 'electronics' },
    { label: 'Clothing', id: 'clothing' },
    { label: 'Books', id: 'books' },
    { label: 'Home & Garden', id: 'home-garden' }
  ]}
  dismissWhenPressedOutside={true}
/>
```

## Tokens

<TokensTable base={BaseDocs} component="MultiSelectFilter" />

### Custom `dictionary` prop

While `MultiSelectFilter` has a default dictionary for various labels for both `en` and `fr` copy, these messages can be overridden by passing a custom `dictionary` prop as shown in the example below.

:::caution
Should you choose to pass a custom `dictionary` prop, you have to provide all the properties in the dictionary for both `en` and `fr`, otherwise the component will not render as expected as it completely overrides the default dictionary instead of merging.
:::

```jsx live
<MultiSelectFilter
  label="MultiSelectFilter"
  subtitle="Subtitle example"
  items={[
    { label: 'Tag 1', id: 'tag1' },
    { label: 'Tag 2', id: 'tag2' },
    { label: 'Tag 3', id: 'tag3' },
    { label: 'Tag 4', id: 'tag4' },
    { label: 'Tag 5', id: 'tag5' }
  ]}
  dictionary={{
    en: {
      filterByLabel: 'Filter by %{filterCategory}:',
      applyButtonLabel: 'Select',
      clearButtonLabel: 'Close'
    },
    fr: {
      filterByLabel: 'Filtrer par %{filterCategory}:',
      applyButtonLabel: 'Sélectionner',
      clearButtonLabel: 'Fermer'
    }
  }}
  onConfirm={(selectedIds) =>
    console.log(`Confirm button clicked with the following selections: ${selectedIds}`)
  }
  onCancel={() => console.log('Cancel/Close button clicked')}
/>
```

## Figma

<FigmaEmbed src="" />

## Variants

<NoStylisticVariants />

## Feedback

<Feedback component="MultiSelectFilter" />
