Home / Function/ searchItems() — ui Function Reference

searchItems() — ui Function Reference

Architecture documentation for the searchItems() function in search.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  c268ce34_f24c_a3dd_6ee3_4e563522e9be["searchItems()"]
  97050a69_2c4b_4c20_ca72_89be3ec705bd["search.ts"]
  c268ce34_f24c_a3dd_6ee3_4e563522e9be -->|defined in| 97050a69_2c4b_4c20_ca72_89be3ec705bd
  e6f35579_6ae8_ff1e_5451_66a5bfd635b0["searchRegistries()"]
  e6f35579_6ae8_ff1e_5451_66a5bfd635b0 -->|calls| c268ce34_f24c_a3dd_6ee3_4e563522e9be
  style c268ce34_f24c_a3dd_6ee3_4e563522e9be fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/shadcn/src/registry/search.ts lines 76–105

function searchItems<
  T extends {
    name: string
    type?: string
    description?: string
    addCommandArgument?: string
    [key: string]: any
  } = SearchableItem
>(
  items: T[],
  options: {
    query: string
  } & Pick<Parameters<typeof fuzzysort.go>[2], "keys" | "threshold" | "limit">
) {
  options = {
    limit: 100,
    threshold: -10000,
    ...options,
  }

  const searchResults = fuzzysort.go(options.query, items, {
    keys: options.keys,
    threshold: options.threshold,
    limit: options.limit,
  })

  const results = searchResults.map((result) => result.obj)

  return z.array(searchableItemSchema).parse(results)
}

Subdomains

Called By

Frequently Asked Questions

What does searchItems() do?
searchItems() is a function in the ui codebase, defined in packages/shadcn/src/registry/search.ts.
Where is searchItems() defined?
searchItems() is defined in packages/shadcn/src/registry/search.ts at line 76.
What calls searchItems()?
searchItems() is called by 1 function(s): searchRegistries.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free