This component no longer exists. It was in cubby-ui’s manifest when we first indexed it and is not there now — the registry served its inventory on 2026-08-10 and this item was not on it. The install command below will fail. It is kept here because a tutorial somewhere still tells people to run it.
useFuzzyFilter
cubby-ui/use-fuzzy-filterRemovedHook
A custom React hook for fuzzy filter.
Install it
npx shadcn@latest add https://cubby-ui.dev/r/use-fuzzy-filter.jsonSource
1import { matchSorter } from "match-sorter";23type Ranking = (typeof matchSorter.rankings)[keyof typeof matchSorter.rankings];45export type FuzzyThreshold =6 | "case-sensitive-equal"7 | "equal"8 | "starts-with"9 | "word-starts-with"10 | "contains"11 | "acronym"12 | "matches";1314const thresholdMap: Record<FuzzyThreshold, Ranking> = {15 "case-sensitive-equal": matchSorter.rankings.CASE_SENSITIVE_EQUAL,16 "equal": matchSorter.rankings.EQUAL,17 "starts-with": matchSorter.rankings.STARTS_WITH,18 "word-starts-with": matchSorter.rankings.WORD_STARTS_WITH,19 "contains": matchSorter.rankings.CONTAINS,20 "acronym": matchSorter.rankings.ACRONYM,21 "matches": matchSorter.rankings.MATCHES,22};2324function resolveThreshold(threshold: FuzzyThreshold | undefined): Ranking | undefined {25 if (!threshold) return undefined;26 return thresholdMap[threshold];27}2829export interface UseFuzzyFilterOptions {30 keys: Array<string | { key: string; threshold?: FuzzyThreshold }>;31 threshold?: FuzzyThreshold;32}3334export function useFuzzyFilter<T>(options: UseFuzzyFilterOptions) {35 const resolvedThreshold = resolveThreshold(options.threshold);36 const resolvedKeys = options.keys.map((key) =>37 typeof key === "string"38 ? key39 : { key: key.key, threshold: resolveThreshold(key.threshold) },40 );4142 const filter = (items: T[], query: string): T[] => {43 if (!query) {44 return items;45 }4647 return matchSorter(items, query, {48 keys: resolvedKeys,49 threshold: resolvedThreshold,50 });51 };5253 const filterItem = (item: T, query: string): boolean => {54 if (!query) {55 return true;56 }5758 const results = matchSorter([item], query, {59 keys: resolvedKeys,60 threshold: resolvedThreshold,61 });6263 return results.length > 0;64 };6566 return { filter, filterItem };67}
What it pulls in
npm packages
