Skip to content

Filter

Open filter choices from a toolbar button and narrow a list by one or more groups of options.

<script setup lang="ts">import { ref } from 'vue'import { UiFilter } from 'grani' const categories = ref(['food', 'fun']) const CATEGORIES = [  { value: 'food', label: 'Food' },  { value: 'transport', label: 'Transport' },  { value: 'fun', label: 'Fun' },]</script> <template>  <UiFilter v-model="categories" label="Categories" :items="CATEGORIES" /></template>

Also called filter dropdown, faceted filter, filter button.

Usage

<UiFilter  :label="label"  :items="items"  v-model="value"/>

With GraniResolver in the Vite config, a template needs no import: set it up once.

API

Name · typeDefaultDescription
Value
modelValueSelectValue[]= [][]One dimension: the chosen values.
Data
itemsSelectOption<SelectValue>[]= [][]One dimension: its options, as a select's (SelectOption).
State
loadingboolean= falsefalseOne dimension: the options are on their way. With none yet, rows in their shape; with options in view, they stay, held and dimmed. Several: each list takes its own.
Behavior
label*stringThe dimension, on the button: "Categories".
countnumberSeveral dimensions: how many of them have a value (status and channel is 2), for the button and Reset. Required with sections: without it the button shows nothing chosen and Reset stays held.
Look
alignstart | center | end= "start""start"Which edge of the button the panel lines up with.
sizexs | sm | mdStep of the control ladder, as the rest of the toolbar row. Unset, the app's size (createGrani({ size })), sm by default.

Attributes: class and style stay on the outer element; the rest (native attributes, aria-*, data-testid) reach the control inside it.

When to use another component

When you needTake
A periodDate range
The columns a table showsTable columns
One value in a formSelect (multiple for several)
CommandsMenu