<!--
  GENERATED FILE - do not edit by hand.
  Source of truth: src/components/mds-filter/ in the magma monorepo (usage/*.md and the
  component's JSDoc). Regenerated on every stencil build (scripts/component-docs.ts).
-->

# mds-filter

> `@maggioli-design-system/magma` 2.15.0. Shadow DOM: style it only through the public CSS custom properties and the parts below.

The `<mds-filter>` web component is a compound container that groups a set of `<mds-filter-item>` chips into a single, scrollable filter bar, coordinating their selection state and exposing the active values as one combined change event. It has no native HTML equivalent: it orchestrates its children rather than rendering a control of its own.

#### Semantic Behavior

- **Compound parent**: Acts as the controller for slotted `<mds-filter-item>` children, driving their state in response to selection events.
- **Group of toggles**: The host is a `group` named by `label`, and each item is a toggle button whose pressed state follows its selection: a screen reader hears which filters are on and how many results each one shows. Every item is a Tab stop; there is no arrow-key navigation.
- **Selection coordination**: In single mode it enforces exclusive selection (selecting one deselects the others); in `multiple` mode it keeps every selected child active and tracks how many are selected.
- **Selection set by the application**: The selection lives on the items' `selected`. Setting or clearing it from the application, or rendering an item already selected, is taken in as after a click: in single mode only the last item set stays selected, the reset button shows or hides, the strip scrolls to the item. No `mdsFilterChange` is emitted for it, and `autoReset` does not apply: the application already knows. Two items `selected` in the markup of a single-mode bar leave the last one selected, as a `<select>` does.
- **Combined change event**: `mdsFilterChange` fires whenever the user changes the selection (an item, or the reset button), carrying both the `NodeList` of the children and a comma-joined string of the selected items' `value`s.
- **Reset control**: When `reset` is set, a clear-all button appears once a filter is active, named in the page language (the `lang` of `<html>`) ("Clear filters"). A click clears all selections and emits `mdsFilterChange` with an empty `value`. While no filter is active the button is scaled away, out of the tab order and of the accessibility tree; without `reset` it is not rendered at all.
- **Auto-scroll**: On each selection the bar scrolls horizontally to center the most recently selected item.
- **Default slot**: The default slot is for `<mds-filter-item>` elements only, not arbitrary text or markup.

#### Properties & Visual Configurations

- **`multiple`** switches the bar from exclusive single-select behavior to allowing several items active at once; choose it when filters are additive rather than mutually exclusive.
- **`reset`** opts the bar into showing a dedicated clear-all control whenever one or more filters are active.
- **`autoReset`** automatically clears all selections once every item has been selected - useful in `multiple` mode where "all selected" is equivalent to "no filter applied".

## Read next

- [`examples.md`](examples.md) - correct usage, from the most common case
- [`mistakes.md`](mistakes.md) - the wrong forms, each with the right one
- [Storybook](https://magma-design-system.github.io/magma/storybook/?path=/docs/ui-filter--docs) - the live examples, in the published Storybook of `main`
- [`conventions.md`](../../../../agents/conventions.md), [`variants.md`](../../../../agents/variants.md), [`mistakes.md`](../../../../agents/mistakes.md) - the rules shared by every component

## Props

| Prop | Attribute | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `autoReset` | `auto-reset` | `boolean \| undefined` | - | Sets an automatic reset of active filters if all filters are triggered |
| `label` | `label` | `string \| undefined` | - | Sets the label of the filter group |
| `multiple` | `multiple` | `boolean \| undefined` | - | Sets if the filter group can filter multiple filters simultaneously |
| `reset` | `reset` | `boolean \| undefined` | - | Shows a reset button if one or more filters are active |

## Events

| Event | Detail | Description |
| --- | --- | --- |
| `mdsFilterChange` | `MdsFilterEventDetail` | Emits when the one of the children is changed |

## Slots

| Slot | Description |
| --- | --- |
| (default) | Add `mds-filter-item` element/s. |

## CSS custom properties

| Property | Description |
| --- | --- |
| `--mds-filter-items-background` | Sets the background-color of the items row area |
| `--mds-filter-items-background-active` | Sets the background-color of the items row area when a filter is active |
| `--mds-filter-wrapper-shadow` | Sets the shadow used as outline border |

Only these are public. Its other 8 are internal: they may change in any release, do not set them.

## Dependencies

Uses: `mds-text`, `mds-filter-item`.
