BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/ilinxa/entity-picker

Entity Picker

ilinxa/entity-picker
FreeBlock

Searchable picker for typed entities — single or multi select, kind badges, chip cluster with removal, and custom render slots.

Install it

npx shadcn@latest add https://ui.ilinxa.com/r/entity-picker.json

Source

src/registry/components/forms/entity-picker/entity-picker.tsxui.ilinxa.com/r/entity-picker.json · first 6 KB
1"use client";
2
3import {
4 useCallback,
5 useId,
6 useImperativeHandle,
7 useLayoutEffect,
8 useRef,
9 useState,
10 type KeyboardEvent,
11 type Ref,
12} from "react";
13import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
14import {
15 Command,
16 CommandEmpty,
17 CommandInput,
18 CommandList,
19} from "@/components/ui/command";
20import type {
21 EntityLike,
22 EntityPickerHandle,
23 EntityPickerProps,
24 KindMeta,
25 MultiPickerProps,
26 PickerMode,
27 SinglePickerProps,
28} from "./types";
29import { defaultMatch } from "./lib/default-match";
30import {
31 multiSelectionEqual,
32 singleSelectionEqual,
33} from "./lib/selection-equality";
34import { useItemsById } from "./hooks/use-items-by-id";
35import { useOpenState } from "./hooks/use-open-state";
36import { TriggerButton } from "./parts/trigger-button";
37import { ResultRow } from "./parts/result-row";
38import { DefaultEmptyState } from "./parts/default-empty-state";
39
40function EntityPickerImpl<T extends EntityLike>(props: EntityPickerProps<T>) {
41 const {
42 items,
43 match,
44 placeholder = "Search…",
45 open: controlledOpen,
46 onOpenChange,
47 kinds,
48 showKindBadges: showKindBadgesProp,
49 renderItem,
50 renderTrigger,
51 renderEmpty,
52 disabled = false,
53 triggerLabel,
54 id,
55 className,
56 ref,
57 } = props;
58
59 const mode: PickerMode = props.mode === "multi" ? "multi" : "single";
60 const value = props.value as T | T[] | null;
61
62 const reactId = useId();
63 const listboxId = `${reactId}-listbox`;
64
65 const { open, setOpen: rawSetOpen } = useOpenState({
66 controlled: controlledOpen,
67 onOpenChange,
68 });
69
70 const [query, setQuery] = useState("");
71
72 const setOpen = useCallback(
73 (next: boolean) => {
74 if (!next) setQuery("");
75 rawSetOpen(next);
76 },
77 [rawSetOpen],
78 );
79
80 const itemsById = useItemsById(items);
81
82 const showKindBadges =
83 showKindBadgesProp !== undefined
84 ? showKindBadgesProp
85 : items.some((i) => !!i.kind);
86
87 // Track the trigger element via state (not a ref) so the setter is React's
88 // own setState — passes the React Compiler-aware lint rule that flags
89 // ref-accessor functions passed to user-rendered functions during render.
90 // The ref-fn is stable across renders (React guarantees setState identity).
91 const [triggerNode, setTriggerNode] = useState<HTMLElement | null>(null);
92
93 // F-cross-13 consumer-trigger path: when a press lands while the popover is
94 // open, Radix/Base UI's outside-press dismiss closes it BEFORE the click
95// … truncated

What it pulls in

npm packages

  • lucide-react

Other registry items

  • badge
  • command
  • popover

Files it writes

  • src/registry/components/forms/entity-picker/entity-picker.tsx
  • src/registry/components/forms/entity-picker/index.ts
  • src/registry/components/forms/entity-picker/types.ts
  • src/registry/components/forms/entity-picker/hooks/use-items-by-id.ts
  • src/registry/components/forms/entity-picker/hooks/use-open-state.ts
  • src/registry/components/forms/entity-picker/lib/default-match.ts
  • src/registry/components/forms/entity-picker/lib/normalize-value.ts
  • src/registry/components/forms/entity-picker/lib/selection-equality.ts
  • src/registry/components/forms/entity-picker/parts/chip-cluster.tsx
  • src/registry/components/forms/entity-picker/parts/chip.tsx
  • src/registry/components/forms/entity-picker/parts/default-empty-state.tsx
  • src/registry/components/forms/entity-picker/parts/kind-badge.tsx
  • src/registry/components/forms/entity-picker/parts/result-row.tsx
  • src/registry/components/forms/entity-picker/parts/trigger-button.tsx

Facts

Registry
ilinxa
Type
registry:block
Access
Free
Files written
14
Licence
MIT
In the index
at or before 2026-08-13
Last confirmed
today

Go to the source

ui.ilinxa.com ilinxa/pro-ui on GitHub Raw registry item This item as JSON

More from ilinxa

All 184 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Account Switcheraccount-switcherilinxaBlocksFree1 dep · 10 files
Account Switcher (deprecated alias)account-switcher-01ilinxaBlocksFreeno deps
Account Switcher — fixturesaccount-switcher-fixturesilinxaBlocksFreeno deps
App Sidebarapp-sidebarilinxaBlocksFree1 dep · 37 files
App Sidebar — fixturesapp-sidebar-fixturesilinxaBlocksFreeno deps
Rich Text Editor (deprecated alias)article-body-01ilinxaBlocksFreeno deps
Article Metaarticle-metailinxaBlocksFree1 dep · 4 files
Article Meta (deprecated alias)article-meta-01ilinxaBlocksFreeno deps
BlockDex

Built by

Kynth Studios

the studio behind StoreReady, ToolDrift and BreachProbe

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product.

BlockDex

BlockDex

Built by

Kynth Studios

the studio behind StoreReady, ToolDrift and BreachProbe

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product.

BlockDex

BlockDex

Built by

Kynth Studios

the studio behind StoreReady, ToolDrift and BreachProbe

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product.

BlockDex