# Filter chips

Source: https://ecosphere.dev/docs/navigation/filter-chips (Ecosphere 1.5). Install `vue-ecosphere` for Vue 3 or `react-ecosphere` for React 18.2+/19: same components, props, markup and stylesheet.

One chip per filterable column, each opening its own menu: a checklist of options, a minimum and maximum, or one exact value.

`import { EcoFilterChips } from "vue-ecosphere"`

## Filter row

Open a chip: Status and Destination apply as each box is ticked; Owner has more than ten options, so it searches; Seats and Age take a range (try a minimum above the maximum); Reference takes one exact value.

Vue (vue-ecosphere):

```vue
<script setup lang="ts">
const filters: EcoFilter[] = [
  { key: "status", label: "Status", options: [{ label: "Pending", value: "Pending" }, …] },
  { key: "destination", label: "Destination", options: […], noun: "destinations" },
  { key: "seats", label: "Seats", kind: "range" },
  { key: "owner", label: "Owner", options: owners, noun: "owners" },  // > 10 → search
  { key: "reference", label: "Reference", kind: "exact", hint: "Enter one exact value. Case and spaces count." },
  { key: "age", label: "Age (days)", kind: "range" },
];
const values = ref({ status: ["Pending", "Blocked", "In review", "Approved"], seats: { min: 10, max: 50 } });
</script>

<EcoFilterChips v-model="values" :filters="filters" label="Filter requests" />
```

React (react-ecosphere):

```tsx
const filters: EcoFilter[] = [
  { key: "status", label: "Status", options: [{ label: "Pending", value: "Pending" }, …] },
  { key: "destination", label: "Destination", options: […], noun: "destinations" },
  { key: "seats", label: "Seats", kind: "range" },
  { key: "owner", label: "Owner", options: owners, noun: "owners" },  // > 10 → search
  { key: "reference", label: "Reference", kind: "exact", hint: "Enter one exact value. Case and spaces count." },
  { key: "age", label: "Age (days)", kind: "range" },
];
const [values, setValues] = useState<EcoFilterValues>({ status: ["Pending", "Blocked", "In review", "Approved"], seats: { min: 10, max: 50 } });

<EcoFilterChips value={values} onChange={setValues} filters={filters} label="Filter requests" />
```

## Multi-select with Apply

Add Apply only where each change costs a slow reload, and keep Clear all beside it.

Vue (vue-ecosphere):

```vue
<EcoFilterChips v-model="values" :filters="[
  { key: 'status', label: 'Status', apply: true, options: [...] },
  { key: 'owner', label: 'Owner', options: owners, noun: 'owners' },
]" />
```

React (react-ecosphere):

```tsx
<EcoFilterChips
  value={values}
  onChange={setValues}
  filters={[
    { key: "status", label: "Status", apply: true, options: [...] },
    { key: "owner", label: "Owner", options: owners, noun: "owners" },
  ]}
/>
```

## API

Vue (vue-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `filters` | `EcoFilter[]` | — | { key, label, kind?: 'options' \| 'range' \| 'exact', options?, noun?, apply?, hint? }, in the table's column order. |
| `v-model` | `Record<string, (string\|number)[] \| { min, max } \| string>` | {} | Current values by filter key; a cleared filter is removed. |
| `label` | `string` | "Filters" | Accessible name of the row (role=group). |
| `clearAllLabel` | `string` | "Clear filters" | The link after the last chip, shown only while something is filtered. |
| `@change` | `(key, value) => void` | — | One filter changed. |

React (react-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `filters` | `EcoFilter[]` | — | { key, label, kind?: 'options' \| 'range' \| 'exact', options?, noun?, apply?, hint? }, in the table's column order. |
| `value / onChange` | `Record<string, (string\|number)[] \| { min, max } \| string>` | {} | Current values by filter key; a cleared filter is removed. |
| `label` | `string` | "Filters" | Accessible name of the row (role=group). |
| `clearAllLabel` | `string` | "Clear filters" | The link after the last chip, shown only while something is filtered. |
| `onFilterChange` | `(key, value) => void` | — | One filter changed (onChange carries every value). |
