home / skills / shipshitdev / library / table-filters

This skill analyzes table columns to design optimal filter UX, outputs a unified filter field with header filters and chips.

This is most likely a fork of the table-filters skill from rohunvora
npx playbooks add skill shipshitdev/library --skill table-filters

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
6.2 KB
---
name: table-filters
description: Designs optimal filtering UX for data tables. Use when building a table that needs filters - analyzes the data columns and determines the best filter type for each. Outputs a unified filter field with inline header filters.
---

# Table Filters

When the user is building a table that needs filters, analyze the columns and design the filtering UX.

## Step 1: Analyze Each Column

For each column in the table, determine the filter type:

| Data Pattern | Filter Type | Example Columns |
|--------------|-------------|-----------------|
| Free text, names, descriptions | **Contains** | Product Name, Notes, Customer |
| Fixed set of values (<20 options) | **Checkboxes** | Status, Category, Priority, Type |
| Numeric values | **Range** | Price, Quantity, Age, Score |
| Dates | **Date Range** | Created, Updated, Due Date |
| Boolean | **Toggle** | Active, Verified, Published |

## Step 2: Implement the Filter Layout

```
┌─────────────────────────────────────────────────────────┐
│ [Filter chips go here...] [🔍 Filter or search...]  [✕] │  ← Unified filter field
└─────────────────────────────────────────────────────────┘
                                          Sort by: [Dropdown ▾]

┌──────────────┬──────────────┬──────────────┬──────────────┐
│ Name       ▼ │ Status     ▼ │ Price      ▼ │ Created    ▼ │  ← Clickable headers with filter icon
├──────────────┼──────────────┼──────────────┼──────────────┤
│ ...          │ ...          │ ...          │ ...          │
```

**Key layout rules:**

- Filter field spans table width, contains chips + search input + clear button
- Sort dropdown next to filter field (not in headers)
- Each header is clickable and opens its filter menu
- Menu appears ABOVE field when filtering (inserts chip directly)

## Step 3: Build Each Filter Component

### Contains Filter (text)

```
┌─ Product Name ──────────── ✕ ─┐
│ ┌────────────────────────────┐│
│ │ Search...                  ││
│ └────────────────────────────┘│
└───────────────────────────────┘
```

Chip result: `Product Name: system`

### Checkbox Filter (categories)

```
┌─ Status ──────────────── ✕ ─┐
│ ☑ Active                     │
│ ☑ Pending                    │
│ ☐ Archived                   │
│ ☐ Deleted                    │
│            [Clear] [Apply]   │
└──────────────────────────────┘
```

Chip result: `Status: Active, Pending` or `Status: Active, +2`

### Range Filter (numeric)

```
┌─ Price ─────────────────── ✕ ─┐
│  Min         Max              │
│ ┌─────┐     ┌─────┐           │
│ │ 0   │  -  │ 100 │           │
│ └─────┘     └─────┘           │
│ ○───────────────●─────○       │  ← Optional slider
│              [Apply]          │
└───────────────────────────────┘
```

Chip result: `Price: $0 - $100`

### Date Range Filter

```
┌─ Created ─────────────────── ✕ ─┐
│  From           To              │
│ ┌──────────┐   ┌──────────┐     │
│ │ 01/01/25 │ - │ 12/31/25 │     │
│ └──────────┘   └──────────┘     │
│ [Today] [This week] [This month]│
│                [Apply]          │
└─────────────────────────────────┘
```

Chip result: `Created: Jan 1 - Dec 31, 2025`

## Chip Design Rules

- Dark background, light text, rounded pill shape
- X button on contrasting surface (clearly clickable)
- Truncate after 2 values: `Status: Active, Pending, +3`
- Clicking chip reopens its filter menu

## Empty State

When filters return no results:

```
     ┌─────────────┐
     │   (╯°□°)╯   │
     │   ︵ ┻━┻    │
     └─────────────┘
   No results found
   Try adjusting your filters

   [Clear all filters]
```

## Quick Checklist

When implementing, verify:

- [ ] Each column has appropriate filter type assigned
- [ ] Filter field contains chips (not separate row above)
- [ ] Sort is dropdown, not toggle icons in headers
- [ ] Chip shows max 2 values, then +N
- [ ] Clear all button at end of filter field
- [ ] Empty state has clear action

## HTML Class Reference

Use these classes for styling compatibility with `html-style`:

| Element | Class | Purpose |
|---------|-------|---------|
| Filter container | `.filter-bar` | Top-level filter row |
| Chip container | `.filter-chips` | Holds all active chips |
| Individual chip | `.chip` | Single filter chip |
| Chip remove | `.chip-remove` | X button on chip |
| Search input | `.filter-search` | Text search field |
| Clear all | `.filter-clear` | Clear all filters button |
| Sort control | `.sort-control` | Sort dropdown container |
| Filter menu | `.filter-menu` | Dropdown filter panel |
| Empty state | `.empty-state` | No results container |

**Data attributes:**

- `data-column` — Column identifier on chips
- `data-filter-type` — Filter type (contains/checkbox/range/date)

## Styling Handoff

This skill outputs semantic HTML with class names. For visual styling, invoke the `html-style` skill after generating filter HTML.

Overview

This skill designs optimal filtering UX for data tables. It analyzes each column and recommends the best filter type, then produces a unified filter field layout with inline header filters and chips. The output is semantic, class-named HTML-ready structure for quick handoff to styling. It’s tailored for tables with mixed data types and interactive header menus.

How this skill works

The skill inspects column metadata (type, value cardinality, sample values) and maps each column to a filter pattern: contains, checkboxes, range, date range, or toggle. It then generates a consistent layout: a full-width filter bar with chips, a search input, clear-all, and a sort dropdown, plus clickable header controls that open context menus and insert chips. Chips are summarized (max two values, then +N), reopen their menus on click, and include data attributes for integration. It outputs semantic HTML class names and a checklist for implementation.

When to use it

  • Building a data table that needs user-facing filters
  • Designing column-level filter UX for mixed data types
  • Creating a single, unified filter bar with per-column menus
  • Preparing a front-end handoff that needs semantic classes and behaviors

Best practices

  • Assign filter types by data pattern: contains, checkboxes (<20 options), range, date range, toggle
  • Use a single filter bar spanning the table with chips, search input, clear-all, and a separate sort dropdown
  • Keep header icons clickable to open per-column menus and make menus insert chips directly into the bar
  • Limit chip verbosity: show up to 2 values then "+N", and make chips reopen their filter menu on click
  • Provide clear empty-state messaging and a prominent Clear All action

Example use cases

  • E-commerce product listing: Name (contains), Category (checkboxes), Price (range), Created (date range)
  • Admin dashboards: User (contains), Status (checkboxes), Last active (date range), Verified (toggle)
  • Inventory tables: Item (contains), Type (checkboxes), Quantity (range), Added date (date range)

FAQ

How do you pick checkboxes vs contains?

If a column has a small fixed set of distinct values (typically under ~20), use checkboxes; otherwise use a contains/text search.

Where should sort controls live?

Put sort as a dropdown adjacent to the unified filter field, not inside table headers, to keep header interactions focused on filtering.