Skip to content

API reference

Import the component and public types from react-lookup-select, not internal source paths. Import default CSS from react-lookup-select/styles.css.

The source package supports React and React DOM 18 and 19. TypeScript consumers need 5.4 or later for the built-in NoInfer used by the shipped declarations. The repository compatibility matrix lists the packed consumer checks.

Prop Type / default
data T[]
dataSource DataSourceFn
columns ColumnDef[] (required)
mapper ValueMapper (required)
mode single / multiple (single)
valueFormat rows / ids / id-text (rows)
value, defaultValue Input matching valueFormat; scalar, array or null
hydrationRows readonly T[]
returnShape id-text / row / custom (id-text)
returnMap ReturnMap<T,R>; required for custom
selectableRow (row: T) => boolean. New selection requires this to allow the row and mapper.getDisabled to leave it enabled. A selected row can still be removed.

If both data and dataSource are provided, the grid uses remote data; local data can still contribute to selection hydration.

Prop Default / type
open, defaultOpen boolean (uncontrolled initially false)
modalTitle i18n.modalTitle or “Select Record”
icon ReactNode
pageSize 20
virtualization false
virtualRowHeight 40 (or measured theme row height)
virtualOverscan 5
virtualContainerHeight 400
virtualThreshold 100
variant default / dark / minimal / compact
size medium / small / large
theme ThemeTokens
classNames ClassNames
styles Styles
i18n Partial i18nStrings overrides with English fallbacks

See custom renderers for the seven render props, selection for callback payloads and timing, and theming for styling parts.

type RowId = string | number;
type IdText = { id: RowId; text: string };
type QueryState = {
page: number;
pageSize: number;
search?: string;
sortBy?: string;
sortDir?: 'asc' | 'desc';
};
type DataSourceFn<T> = (query: QueryState) =>
Promise<{ rows: T[]; total: number }>;

ColumnDef<T> has key, title, optional width, sortable and render(row, index). ValueMapper<T> has getId, getText and optional getDisabled. ReturnMap<T,R> has map(row) returning R.

The component infers output shape from mode, returnShape and returnMap. You can explicitly use LookupSelect<T, 'multiple', 'custom', R> for a custom projection, or use LookupSelectProps<T, M, S, R> when typing a wrapper.

  • Component: LookupSelectProps.
  • Selection: SelectMode, RowId, IdText, SelectionOutput, SelectionInputProps, ValueFormat, ValueMapper, ReturnShape, ReturnMap.
  • Grid: ColumnDef, VirtualizationConfig, GridRenderProps.
  • Data: QueryState, DataSourceResult, DataSourceFn.
  • Styling: ClassNames, Styles, PartStyle, ThemeTokens, Theme, Size.
  • Renderers: ModalRenderProps, HeaderRenderProps, FooterRenderProps, SearchRenderProps, PaginationRenderProps.
  • Localization: i18nStrings.

The source of truth for the public surface is src/index.ts and the exported type definitions.