@molecule/app-tab-filter-solid

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-solid

npm · Source on GitHub

How it works

@molecule/app-tab-filter-solid 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 { createSignal } from 'solid-js'

import { TabFilter } from '@molecule/app-tab-filter-solid'

function TicketFilters() {
  const [activeTab, setActiveTab] = createSignal('all')
  const tabs = [
    { id: 'all', label: 'All', count: 42 },
    { id: 'open', label: 'Open', count: 8 },
    { id: 'closed', label: 'Closed', count: 34 },
  ]
  return (
    <TabFilter
      defaultTab={{ id: 'all', label: 'All' }}
      tabs={tabs}
      activeId={activeTab()}
      onChange={setActiveTab}
    />
  )
}

Works with: @molecule/app-solid, @molecule/app-ui, @molecule/app-ui-solid

Reference

Solid 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.ts JSDoc, not this file.

Quick Start

import { createSignal } from 'solid-js'

import { TabFilter } from '@molecule/app-tab-filter-solid'

function TicketFilters() {
  const [activeTab, setActiveTab] = createSignal('all')
  const tabs = [
    { id: 'all', label: 'All', count: 42 },
    { id: 'open', label: 'Open', count: 8 },
    { id: 'closed', label: 'Closed', count: 34 },
  ]
  return (
    <TabFilter
      defaultTab={{ id: 'all', label: 'All' }}
      tabs={tabs}
      activeId={activeTab()}
      onChange={setActiveTab}
    />
  )
}

Type

feature

Installation

npm install @molecule/app-tab-filter-solid @molecule/app-solid @molecule/app-ui @molecule/app-ui-solid solid-js

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: JSX.Element
  /** Optional leading icon. */
  icon?: JSX.Element
  /** 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
}

Functions

TabFilter(props)

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.

React keys each tab button by the tab's id, so a re-ordered or re-passed array moves/keeps the rendered buttons per key. Solid's For keys by reference, so the buttons are keyed through stable per-id records: the record for an id is created once and reused, while the button reads the CURRENT tab for its id reactively.

This is the Solid counterpart of @molecule/app-tab-filter-react: the same props (React names), the same ClassMap tokens, and the same DOM for the same input.

function TabFilter(props: TabFilterProps): JSX.Element
  • props — Component props (see TabFilterProps).

Returns: The rendered tab filter.

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-solid ^3.5.0 || ^4.0.0
  • @molecule/app-ui ^1.1.0
  • @molecule/app-ui-solid ^1.1.0
  • solid-js ^1.8.0

Runtime Dependencies

  • @molecule/app-solid

  • @molecule/app-ui

  • @molecule/app-ui-solid

  • solid-js

  • Requires a wired ClassMap bond (getClassMap() throws before bonding). Labels are nodes — pass translated strings.

  • The default filled pill backgrounds use Material-3 token utilities that only produce CSS when the app theme defines those tokens. In token-less apps pass filled={false} (font-weight-only active state) or add the tokens.

  • Counts render via toLocaleString(); disabled tabs are non-interactive. Keyboard interaction is click/tab-focus only — no roving arrow-key navigation.