filter-sphere

star 34

Integrate Filter Sphere into a project - schema-driven filtering for Zod-typed data. Use when building filtering UIs, data tables with filters, or adding sort/filter logic to any TypeScript application.

lawvs By lawvs schedule Updated 2/17/2026

name: filter-sphere description: Integrate Filter Sphere into a project - schema-driven filtering for Zod-typed data. Use when building filtering UIs, data tables with filters, or adding sort/filter logic to any TypeScript application.

Filter Sphere - Schema-driven Filtering

Build advanced filtering interfaces powered by Zod schemas.

Quick Start

# React filter UI
pnpm add @fn-sphere/filter zod

Core Concepts

Basic Setup

import {
  FilterSphereProvider,
  FilterBuilder,
  useFilterSphere,
} from "@fn-sphere/filter";
import { z } from "zod";

// 1. Define your data schema with Zod
const schema = z.object({
  name: z.string().describe("Name"),
  age: z.number().describe("Age"),
});

export function FilterBuilder() {
  // 2. use the `useFilterSphere` hook to get the context and predicate
  const { filterRule, predicate, context } = useFilterSphere({
    schema,
    onRuleChange: ({ filterRule }) => {
      console.log("Filter rule changed:", filterRule);
    },
  });

  const data = [
    /* ... */
  ];

  // 4. use the `predicate` to filter the data
  const filteredData = data.filter(predicate);

  return (
    // 3. display the `FilterBuilder` inside the `FilterSphereProvider`
    <FilterSphereProvider context={context}>
      <FilterBuilder />
    </FilterSphereProvider>
  );
}

Project Structure (Recommended)

filter-sphere/
  index.tsx      # Main component wiring everything together
  schema.ts      # Zod schema, default rules, custom functions
  theme.tsx      # Theme via createFilterTheme
  locale.ts      # (Optional) i18n with getLocaleText

Core References

Topic Reference
Introduction Introduction
Getting Started Getting Started
Best Practices Best Practices
Work with AI Work with AI
Customizing Filters Customizing Filters
Customizing Theme Customizing Theme
Customizing Data Input Data Input
Persistence Persistence
Preset Filters Preset Filters
Example Example

Resources

Install via CLI
npx skills add https://github.com/lawvs/fn-sphere --skill filter-sphere
Repository Details
star Stars 34
call_split Forks 1
navigation Branch main
article Path SKILL.md
More from Creator