@molecule/app-tab-filter-vue
Feature · tab-filter · App (browser) · v1.1.2 · Apache-2.0
Horizontal pill-tab filter with optional count badges and icons
npm install @molecule/app-tab-filter-vueHow it works
@molecule/app-tab-filter-vue is a ready-made tab-filter feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
import { defineComponent, h, ref } from 'vue'
import { TabFilter } from '@molecule/app-tab-filter-vue'
const TicketFilters = defineComponent({
setup() {
const activeTab = ref('all')
const tabs = [
{ id: 'all', label: 'All', count: 42 },
{ id: 'open', label: 'Open', count: 8 },
{ id: 'closed', label: 'Closed', count: 34 },
]
return () =>
h(TabFilter, {
defaultTab: { id: 'all', label: 'All' },
tabs,
activeId: activeTab.value,
onChange: (id: string) => {
activeTab.value = id
},
})
},
})Works with: @molecule/app-ui, @molecule/app-ui-vue, @molecule/app-vue
Reference
Vue tab-style filter with inline count badges.
Exports <TabFilter> — horizontally-scrolling pill-tabs with counts —
and the TabFilterTab type. Different from a plain tabs row: this one
surfaces per-tab count badges and scrolls horizontally on overflow. Set
defaultTab to the collection's unfiltered view: it remains reachable when
tabs changes to a path/query-selected filter. A duplicate id appears once,
using the default tab's definition. Pass its id to the same onChange
navigation callback. Applications without a default view can omit it.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
import { defineComponent, h, ref } from 'vue'
import { TabFilter } from '@molecule/app-tab-filter-vue'
const TicketFilters = defineComponent({
setup() {
const activeTab = ref('all')
const tabs = [
{ id: 'all', label: 'All', count: 42 },
{ id: 'open', label: 'Open', count: 8 },
{ id: 'closed', label: 'Closed', count: 34 },
]
return () =>
h(TabFilter, {
defaultTab: { id: 'all', label: 'All' },
tabs,
activeId: activeTab.value,
onChange: (id: string) => {
activeTab.value = id
},
})
},
})
Type
feature
Installation
npm install @molecule/app-tab-filter-vue @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue
API
Interfaces
TabFilterTab
Shape of a single tab entry passed to TabFilter.
interface TabFilterTab {
/** Unique id / state key. */
id: string
/** Display label. Pass translated text, or any node. */
label: VNodeChild
/** Optional leading icon. */
icon?: VNodeChild
/** Optional count badge (e.g. number of items matching this filter). */
count?: number
/** When true, the tab renders disabled. */
disabled?: boolean
}
TabFilterProps
Props accepted by the TabFilter component.
interface TabFilterProps {
/** Tabs to render. */
tabs: TabFilterTab[]
/** Persistent collection/default view, retained even when tabs contains only the active filter. */
defaultTab?: TabFilterTab
/** Currently active tab id. */
activeId: string
/** Called when an enabled tab is clicked. */
onChange: (id: string) => void
/** Whether to allow the row to scroll horizontally. Defaults to true. */
scrollable?: boolean
/**
* When `true` (default), draws filled-pill backgrounds matching the
* polished flagship apps. Pass `false` for the older bare-text-only style.
*/
filled?: boolean
/** Extra classes. */
className?: string
}
Constants
TabFilter
Horizontal pill-style tab row used as a segmented filter.
Different from a plain tabs row in surfacing inline count badges per tab
and scrolling horizontally on overflow. defaultTab stays reachable when
tabs holds only the path/query-selected filter, and a duplicate id
appears once (using the default tab's definition). Each enabled tab calls
onChange with its own id; disabled tabs are non-interactive.
const TabFilter: DefineComponent<
ExtractPropTypes<{
tabs: { type: PropType<TabFilterTab[]>; required: true }
defaultTab: { type: PropType<TabFilterTab>; default: undefined }
activeId: { type: StringConstructor; required: true }
onChange: { type: PropType<(id: string) => void>; required: true }
scrollable: { type: BooleanConstructor; default: boolean }
filled: { type: BooleanConstructor; default: boolean }
className: StringConstructor
}>,
() => VNode,
{},
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
{},
string,
PublicProps,
Readonly<
ExtractPropTypes<{
tabs: { type: PropType<TabFilterTab[]>; required: true }
defaultTab: { type: PropType<TabFilterTab>; default: undefined }
activeId: { type: StringConstructor; required: true }
onChange: { type: PropType<(id: string) => void>; required: true }
scrollable: { type: BooleanConstructor; default: boolean }
filled: { type: BooleanConstructor; default: boolean }
className: StringConstructor
}>
> &
Readonly<{}>,
{ defaultTab: TabFilterTab; scrollable: boolean; filled: boolean },
{},
{},
{},
string,
ComponentProvideOptions,
true,
{},
any
>
props— Component props (seeTabFilterProps).
Returns: The tab filter component.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-ui^1.1.0@molecule/app-ui-vue^1.1.0@molecule/app-vue^3.5.0 || ^4.0.0vue^3.4.0
Runtime Dependencies
-
@molecule/app-ui -
@molecule/app-ui-vue -
@molecule/app-vue -
vue -
Requires a wired ClassMap bond (
getClassMap()throws before bonding). Labels are nodes — pass translated strings. -
The default
filledpill backgrounds use Material-3 token utilities that only produce CSS when the app theme defines those tokens. In token-less apps passfilled: false(font-weight-only active state) or add the tokens. -
Counts render via
toLocaleString();disabledtabs are non-interactive. Keyboard interaction is click/tab-focus only — no roving arrow-key navigation.