Skip to content

Filter Bar ​

FTFilterBar is the filter part of a list page toolbar. It holds:

  • the Filter button: every filter the page offers (FTFilterMenu);
  • the pinned filters: chips that always show, each opening only its own values;
  • the added filters: filters with values that are not pinned, on a second row as "Field is value", with a remove button;
  • Clear filters: after the added filters, or on the first row when only pinned filters have values.

The page owns the values and the pinned ids. The bar requests changes; the page applies them and passes them back.

Contract: src/components/FTFilterBar/contract.ts (status: draft). History: contract-log.md.

Basic usage ​

vue
<script setup lang="ts">
import { ref } from 'vue';
import { FTFilterBar } from '@fasttrack-solutions/vue-components-lib';
import type {
  FTFilterMenuFilter,
  FTFilterMenuValue,
} from '@fasttrack-solutions/vue-components-lib';

const pinned = ref<string[]>(['origin', 'status']);
const filters = ref<FTFilterMenuFilter[]>([
  /* every filter, with its options and values */
]);

const update = (id: string, values: FTFilterMenuValue[]) => {
  filters.value = filters.value.map((f) => (f.id === id ? { ...f, values } : f));
};
const togglePin = (id: string) => {
  pinned.value = pinned.value.includes(id)
    ? pinned.value.filter((p) => p !== id)
    : [...pinned.value, id];
};
const clear = () => {
  filters.value = filters.value.map((f) => ({ ...f, values: [] }));
};
</script>

<template>
  <FTFilterBar
    :filters="filters"
    :pinned="pinned"
    pinnable
    @update="update"
    @toggle-pin="togglePin"
    @clear="clear"
  />
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { FTFilterBar } from '@fasttrack-solutions/vue-components-lib';
import type {
  FTFilterMenuFilter,
  FTFilterMenuValue,
} from '@fasttrack-solutions/vue-components-lib';

const pinned = ref<string[]>(['origin', 'status']);
const filters = ref<FTFilterMenuFilter[]>([
  /* every filter, with its options and values */
]);

const update = (id: string, values: FTFilterMenuValue[]) => {
  filters.value = filters.value.map((f) => (f.id === id ? { ...f, values } : f));
};
const togglePin = (id: string) => {
  pinned.value = pinned.value.includes(id)
    ? pinned.value.filter((p) => p !== id)
    : [...pinned.value, id];
};
const clear = () => {
  filters.value = filters.value.map((f) => ({ ...f, values: [] }));
};
</script>

<template>
  <FTFilterBar
    :filters="filters"
    :pinned="pinned"
    pinnable
    @update="update"
    @toggle-pin="togglePin"
    @clear="clear"
  />
</template>

Chip text ​

SelectionThe pinned chip shows
NoneThe filter label
One valueLabel: value
More valuesThe label and a count
Options with a colourThe selected colours as dots
Options with a logoUp to five logos, then a 5+ count

Props ​

PropTypeDefaultDescription
filtersFTFilterMenuFilter[]requiredEvery filter, with its options and selected values
pinnedstring[][]Ids of the filters that show as chips
pinnablebooleanfalseThe menus show the pin toggle
searchablebooleanfalseShows a search in the Filter menu. Pinned chips never show it
disabledbooleanfalseTurns off every control and closes open menus, for example while a bulk action bar covers the toolbar
labelstring'Filter'Name of the bar and of the Filter button
clearLabel, isLabel, removeLabelstringEnglish textTranslated labels
menuTextFTFilterBarMenuText{}Translated text for the menus: searchPlaceholder, allFiltersLabel, noMatchText, clearLabel, backLabel, pinLabel, unpinLabel, pinnedLabel

Events ​

EventPayloadDescription
updateid, valuesA selection change request for one filter
toggle-pinidA pin change request
clearnoneA request to clear every filter

Slots ​

SlotDescription
endControls after the filters on the first row. They stay the page's: disabled does not reach them, so disable them yourself while a bulk bar covers the toolbar.

CSS custom properties ​

PropertyDefault
--ft-filter-bar-control-heightcalc(var(--spacing-xl) + var(--spacing-xs) + var(--spacing-2xs))
--ft-filter-bar-chip-bgvar(--color-mono-100)
--ft-filter-bar-chip-bordervar(--color-mono-300)
--ft-filter-bar-chip-hover-bgvar(--color-mono-200)
--ft-filter-bar-chip-hover-bordervar(--color-mono-400)
--ft-filter-bar-chip-on-bgvar(--color-brand-blue-100)
--ft-filter-bar-chip-onvar(--color-brand-blue-500)
--ft-filter-bar-chip-on-hover-bgvar(--color-brand-blue-200)
--ft-filter-bar-chip-open-bordervar(--color-brand-blue-600)
--ft-filter-bar-chip-on-iconvar(--color-brand-blue-600)