WlFilterBar

Desktop filter toolbar and mobile Drawer. Supports focus management, Escape closing, clearing and applying filters.
Components / Composites v0.3.0

Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.

Settings

density
activeCount

Number of active filters.

ariaLabel

Uses locale.filters when omitted or undefined; English fallback: Filters.

toggleLabel

Uses locale.filters when omitted or undefined; English fallback: Filters.

panelTitle

Uses locale.filters when omitted or undefined; English fallback: Filters.

clearLabel

Uses locale.reset when omitted or undefined; English fallback: Reset.

applyLabel

Uses locale.apply when omitted or undefined; English fallback: Apply.

closeLabel

Uses locale.closeFilters when omitted or undefined; English fallback: Close filters.

Props pt, models, handlers and slots can be edited in the SFC. See their descriptions in API.

Example

Filters
Focus: outside the example · pointer: outside the example

Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.

Code for your application

Vue SFC · current settings
<script setup lang="ts">
import { WlFilterBar, WlInput, WlSelect, WlTag } from "legato-ui";
import { ref } from "vue";
const search = ref("");
const status = ref<string | null>(null);
</script>

<template>
  <div class="wl-stack" data-space="md">
    <WlFilterBar
      :active-count="Number(Boolean(search)) + Number(Boolean(status))"
      
      @clear="search = ''; status = null"
    ><template #leading><WlInput
      v-model="search"
      type="search"
      aria-label="Search materials"
      placeholder="Search"
    /></template><WlSelect
      v-model="status"
      :options="[{ label: 'Done', value: 'done' }, { label: 'In progress', value: 'progress' }]"
      option-label="label"
      option-value="value"
      aria-label="Status"
      placeholder="All statuses"
    /><template #summary><WlTag v-if="status" removable @remove="status = null">{{ status }}</WlTag></template></WlFilterBar>
  </div>
</template>

Search, filters and mobile panel

Leading, controls, actions, summary, removing active filters, clear/apply and the named open model.

Material filters
No active filters

Active filters: 0. Applications: 0. Settings open in a drawer on narrow screens.

Vue SFC · additional example
<script setup lang="ts">
import { WlButton, WlFilterBar, WlInput, WlSelect, WlTag } from "legato-ui";
import { computed, ref } from "vue";
const search = ref("");
const status = ref<string | null>(null);
const open = ref(false);
const applied = ref(0);
const statuses = [{ label: "Done", value: "done" }, { label: "In progress", value: "progress" }];
const count = computed(() => Number(Boolean(search.value)) + Number(Boolean(status.value)));
function clear(): void {
  search.value = "";
  status.value = null;
}
</script>

<template>
  <div class="wl-stack" data-space="lg">
    <WlFilterBar
      v-model:open="open"
      class="showcase-filters"
      :active-count="count"
      aria-label="Material list filters"
      toggle-label="Configure filters"
      panel-title="Material filters"
      @clear="clear"
      @apply="applied++"
    >
      <template #leading><WlInput
        v-model="search"
        type="search"
        aria-label="Search the material list"
        placeholder="Material title"
      /></template>
      <WlSelect
        v-model="status"
        :options="statuses"
        option-label="label"
        option-value="value"
        aria-label="Material list status"
        placeholder="All statuses"
      />
      <template #actions="{ clear: clearValues }">
        <WlButton
          size="sm"
          variant="ghost"
          :disabled="count === 0"
          @click="clearValues"
        >{{ "Reset list filters" }}</WlButton>
        <WlButton size="sm" @click="applied++">{{ "Apply on desktop" }}</WlButton>
      </template>
      <template #summary>
        <div class="wl-inline" data-space="sm">
          <WlTag
            v-if="search"
            removable
            :remove-label="'Remove search ' + search"
            @remove="search = ''"
          >{{ "Search:" }} {{ search }}</WlTag>
          <WlTag
            v-if="status"
            color="blue"
            removable
            remove-label="Remove status filter"
            @remove="status = null"
          >{{ statuses.find(item => item.value === status)?.label }}</WlTag>
          <span v-if="!count" class="wl-text-small wl-text-muted">{{ "No active filters" }}</span>
        </div>
      </template>
    </WlFilterBar>
    <p class="wl-text-small" role="status">
      {{ "Active filters:" }} {{ count }}{{ ". Applications:" }}
      {{ applied }}{{ ". Settings open in a drawer on narrow screens." }}
    </p>
  </div>
</template>

<style scoped>
@media (min-width: 721px) { .showcase-filters :deep(.wl-filter-bar__toolbar) { flex-wrap: wrap; } }
</style>