← Blog
11 Oct 2026tags componentVue 3dashboard filtersaccessibilityUI patterns

Tags Component for Vue Dashboards: Build Filters and Selected Tokens That Stay in Sync

Build a tags component pattern for Vue dashboards with accessible category filters, synchronized removable tokens, readable statuses, and responsive layouts.

Tags Component for Vue Dashboards: Build Filters and Selected Tokens That Stay in Sync

TL;DR

For a dashboard tags component, keep status and category labels as text, use toggle buttons for filters, and derive removable selected tokens from the same filter state. Give every removal button a specific name and return focus to its filter control. The Vue example below shows all four pieces together.

A category may appear in a table row, a filter toolbar, and a selected-filter summary. Those three appearances should agree about the category, but they should not all behave like buttons. We will build one small screen in which filtering and removal stay synchronized, including the less obvious case where removing a token makes its focused button disappear.

Table of contents

Before you start

You need a Vue 3 project that renders Single-File Components, a screen with records identified by stable IDs, and permission to change its filter UI. The example uses only Vue and native HTML; it does not require a DOM Studio package. Keep your browser’s keyboard navigation and a narrow viewport handy. If your records are loaded from a server, identify who owns the query, loading state, and result count before adapting the local-data example.

Our sample uses categories Analytics, Billing, and Archive, plus read-only workflow statuses. Archive intentionally has no matching record so we can check the empty state. We will use the Carbon Design System’s tag variants as a behavior reference, not as a requirement to adopt its styling. Carbon distinguishes read-only, selectable, dismissible, and operational tags; the GOV.UK Design System’s status tag is deliberately noninteractive. Choose the interaction contract before the shape.

1. Assign each tag one job

Sketch where each compact label lives and what it does. In the table, Billing describes a record, while Pending reports its status. Neither needs focus or a click handler. Above the table, Billing narrows the results and belongs on a button. In a selected-filter summary, Billing has a separate Remove Billing filter button. Do not attach removal to the static category in the table or make a status pill double as navigation.

Where the label appears User job Starting element
Category cell Read an attribute Text inside a span
Status cell Read a workflow state Text inside a span
Filter toolbar Toggle an active constraint button with stable label and aria-pressed
Selected-filter summary Remove an active constraint Text token with a separately named button

A badge might emphasize a count; a chip or pill might describe a shape. Those names cannot tell you whether a control is interactive. When choosing among a tag, button, dropdown, or combobox, start with the task: visible short choices favor buttons, a long searchable vocabulary favors a picker, and status alone favors plain text. Carbon’s guidance also cautions against giving a single tag multiple functions.

Four-way visual decision flow for static category, status, selectable filter, and removable token

Check: every proposed element has one verb: read, toggle, remove, or choose from a list. If a designer expects a static status to open a detail page, introduce a clearly identifiable link elsewhere instead of hiding navigation inside status styling.

2. Establish labels and a single source of selection state

Use a stable category ID for the data operation and a human-readable label for display. A record might store billing while the toolbar says Billing. Order filter choices consistently across the toolbar and selected summary so users can recognize the same category without searching in a new sequence. For a status, prefer a state description such as Needs review rather than the command Review. GOV.UK explicitly recommends descriptive status names rather than action words in its noninteractive tag pattern.

The state contract for our example is small: an array of selected category IDs, a computed array of visible records, and a selected-token list derived from those same IDs. Clicking a filter and clicking its selected-token remove button both update that one array. We do not store a second, independently editable list of selected tokens. Vue’s computed-property documentation explains how derived values track reactive dependencies.

Specify content edge cases now, not after the layout breaks. Decide how to show an unknown category, a pending or failed data request, and a long user-defined name. If the toolbar contains dozens of choices, replace the always-visible button group with an appropriately labeled picker rather than wrapping ten rows of tiny controls. A tag-entry field solves a different job: DOM Studio’s Tag Combobox documentation describes searching or adding values as removable field tokens. It is not a substitute for displaying row status.

Check: write down the expected results when no filter is selected, when two filters are selected, and when one selected token is removed. For this example, no selection shows every record, and selecting Archive alone shows a clear zero-result message.

The following video demonstrates the visual design of chip components in Figma. Use it for spacing and state ideas, then verify the web behavior with the keyboard and screen-reader checks below.

3. Implement a Vue filter toolbar with synchronized tokens

Put the following component in a Vue 3 Single-File Component and render it inside an existing page. It uses Vue’s documented v-for and stable keys, ref and computed state, and nextTick to wait for the DOM after removing a selected token. The WAI-ARIA button pattern supports aria-pressed for a button whose label stays the same while its on/off state changes.

<script setup>
import { computed, nextTick, ref } from 'vue'

const categories = [
  { id: 'analytics', label: 'Analytics' },
  { id: 'billing', label: 'Billing' },
  { id: 'archive', label: 'Archive' }
]
const records = ref([
  { id: 'r1', name: 'Usage report', category: 'analytics', status: 'Ready' },
  { id: 'r2', name: 'Invoice review', category: 'billing', status: 'Needs review' },
  { id: 'r3', name: 'Growth report', category: 'analytics', status: 'Ready' }
])
const selectedIds = ref(['billing'])
const filterButtons = new Map()

const selectedCategories = computed(() =>
  categories.filter(category => selectedIds.value.includes(category.id))
)
const visibleRecords = computed(() =>
  selectedIds.value.length === 0
    ? records.value
    : records.value.filter(record => selectedIds.value.includes(record.category))
)

function toggle(id) {
  selectedIds.value = selectedIds.value.includes(id)
    ? selectedIds.value.filter(value => value !== id)
    : [...selectedIds.value, id]
}

async function remove(id) {
  selectedIds.value = selectedIds.value.filter(value => value !== id)
  await nextTick()
  filterButtons.get(id)?.focus()
}

function categoryName(id) {
  return categories.find(category => category.id === id)?.label ?? 'Uncategorized'
}
</script>

<template>
  <section aria-labelledby="queue-heading">
    <h2 id="queue-heading">Review queue</h2>
    <fieldset class="filters">
      <legend>Filter by category</legend>
      <div class="tag-row">
        <button
          v-for="category in categories"
          :key="category.id"
          :ref="el => { if (el) filterButtons.set(category.id, el) }"
          type="button"
          class="filter-tag"
          :class="{ 'filter-tag--active': selectedIds.includes(category.id) }"
          :aria-pressed="selectedIds.includes(category.id)"
          @click="toggle(category.id)"
        >{{ category.label }}</button>
      </div>
    </fieldset>

    <div v-if="selectedCategories.length" class="selected" aria-label="Active filters">
      <span class="selected-label">Active filters:</span>
      <span v-for="category in selectedCategories" :key="category.id" class="token">
        <span>{{ category.label }}</span>
        <button
          type="button"
          :aria-label="`Remove ${category.label} filter`"
          @click="remove(category.id)"
        >×</button>
      </span>
    </div>

    <p role="status">{{ visibleRecords.length }} records shown.</p>
    <div class="table-scroll">
      <table>
        <caption>Records by category and status</caption>
        <thead><tr><th scope="col">Record</th><th scope="col">Category</th><th scope="col">Status</th></tr></thead>
        <tbody>
          <tr v-for="record in visibleRecords" :key="record.id">
            <th scope="row">{{ record.name }}</th>
            <td><span class="read-tag">{{ categoryName(record.category) }}</span></td>
            <td><span class="read-tag">{{ record.status }}</span></td>
          </tr>
        </tbody>
      </table>
    </div>
    <p v-if="!visibleRecords.length">No records match. Choose another category.</p>
  </section>
</template>

<style scoped>
.filters { border: 0; margin: 0; padding: 0; }
.tag-row, .selected { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.selected { margin-block: 1rem; }
.filter-tag, .token, .read-tag { border-radius: 999px; font: inherit; }
.filter-tag { min-height: 2.75rem; padding: .4rem .8rem; border: 2px solid #334155; background: #fff; color: #172033; cursor: pointer; }
.filter-tag--active { background: #172033; color: #fff; }
.token { display: inline-flex; align-items: center; gap: .25rem; border: 1px solid #334155; padding-left: .7rem; background: #fff; color: #172033; }
.token button { min-width: 2.75rem; min-height: 2.75rem; border: 0; border-radius: 999px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.read-tag { display: inline-block; max-width: 100%; padding: .2rem .6rem; background: #e2e8f0; color: #172033; overflow-wrap: anywhere; }
.filter-tag:focus-visible, .token button:focus-visible { outline: 3px solid #264db8; outline-offset: 2px; }
.table-scroll { max-width: 100%; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 32rem; }
th, td { padding: .75rem; text-align: left; border-bottom: 1px solid #cbd5e1; }
</style>

Expected result: the Billing filter starts pressed and displays one record plus one removable token. Removing that token restores all three records and focuses the Billing filter button. Select Analytics and Billing together to display three records with two removable tokens; select Archive alone to get zero records and the visible recovery message. Because the category and status cells are plain text, tabbing skips them while reaching the actual controls.

Troubleshooting: if selecting a filter does not change rows, compare record.category with the category IDs; matching display labels is not enough. If removal seems to lose keyboard focus, check that the corresponding filter button remains rendered, and do not reuse the table’s element as a fallback. The sample deliberately omits API fetching, pagination, authorization, and URL synchronization. For remote results, the page must handle request failures, loading feedback, stale responses, and whether the count reflects the current query, not just the loaded page. The example has not been executed as part of this article; run it in your application before using it in production.

4. Fit tags into dense and narrow application views

Let the filter toolbar and selected-token row wrap as groups; do not force all options into one horizontal strip on a phone. Our sample allows the table itself to scroll if its columns need more width. On a real dashboard, choose what stays visible first: a row’s status is usually more important than a decorative category treatment. Do not hide the only readable status behind a hover-only tooltip. DOM Studio’s Application Layout block provides a separate example of how a persistent sidebar and scrolling work area coexist, but this page-level filter state belongs with the dashboard feature rather than the global shell.

Desktop and mobile dashboard views showing wrapped filter tags and legible status labels

Test long labels and translation before limiting widths. A user-defined 40-character category should have a discoverable full name, not an ellipsis that can only be deciphered with a mouse. The code breaks a long read-only label if needed; for very long filter button names, consider a clearer selection UI instead of shrinking text indefinitely. Prefer a visible Show all or picker control over silently dropping options from the tab sequence. Carbon’s tag guidance also treats overflow as a deliberate disclosure behavior.

Check: at a narrow width and at 200% zoom, the last filter and its focus ring remain reachable, removal does not cover another token, and the status cell remains legible. If the table takes over horizontal scrolling, keep its heading and filter controls outside that scroll container.

5. Verify accessible states and ship the pattern

Do not use color as the only source of meaning. The words Ready and Needs review carry the status even if the palette changes; the toolbar buttons communicate selection programmatically with aria-pressed. The W3C button pattern specifies Enter and Space activation and recommends keeping a toggle’s label stable. Native buttons provide that basic keyboard behavior without custom key listeners.

For ordinary tag text, WCAG 2.2’s minimum contrast guidance sets 4.5:1 as the Level AA threshold, with exceptions including large text. Where a border or state cue is necessary to identify an interactive filter, non-text contrast guidance sets 3:1 against adjacent colors. WCAG 2.2’s target size minimum is 24 by 24 CSS pixels, subject to listed exceptions such as spacing; the example chooses a roomier hit area. These are requirements to check against your rendered theme, not a certification of these illustrative CSS values.

Walk through a final acceptance check with a keyboard and, where available, a screen reader:

  • Tab through the filters and hear a stable name and pressed state for each; confirm table labels are not extra stops.
  • Activate two filters with Space and Enter. Confirm the row count, tokens, and records describe the same selection.
  • Remove one token and confirm the corresponding toolbar button receives focus after its token disappears.
  • Choose Archive alone and confirm the zero-result message differs from an API failure or a loading state.
  • Try an unknown category, long translated label, disabled permission-controlled filter, and selected state in every supported theme. Add disabled or loading states only where your product actually needs them.

If this works in an isolated example but fails after integrating a server query, keep the selection state in the page and pass the chosen IDs to the data layer. Do not announce a stale result count as if a new query has finished. Your completed outcome is a tag pattern whose appearance is shared while its read, toggle, and remove actions remain distinct. The next useful action is to apply it to one real dashboard screen and test both a full and an empty result set.

If the work expands from dashboard filtering to entering new categories in a form, inspect the DOM Studio Tag Combobox playground for a purpose-built token-entry interaction rather than adding typing behavior to the filter bar.

Frequently asked questions

Should a selected filter token also be a toggle button?

Not in this design. The toolbar button toggles selection; the summary token identifies an active constraint and offers a separately named remove button. Both controls update the same selected IDs. That separation avoids an ambiguous token that toggles and removes depending on where someone clicks.

What happens to focus when someone removes a token?

If the removal button disappears, move focus to a predictable surviving control. This example returns it to the corresponding filter button after Vue’s next DOM update. For a tag-entry form, returning focus to the text field or an adjacent remaining token may fit better; test the actual editing task.

Sources

Recommended Reads