Skip to content

Custom renderers

Column renderers replace the display of individual cells. The data field key still determines built-in local search and sorting.

const columns: ColumnDef<Part>[] = [
{ key: 'name', title: 'Part' },
{ key: 'stock', title: 'Stock', render: row => <strong>{row.stock}</strong> },
];

Use render props to replace larger UI surfaces. The library supplies data and state transitions; your renderer owns its DOM and presentation.

Prop Responsibility
renderTrigger Receives hydrated committed rows as one row or null in single mode, or an array in multiple mode.
renderModal ModalRenderProps<T> supplies isOpen, onClose, header, children, optional query/loading/error and selection counts.
renderHeader HeaderRenderProps<T> supplies title, close, search and clear-all controls and counts. The library still renders its search area separately.
renderGrid GridRenderProps<T> supplies visible rows, columns, selected IDs, eligibility, sorting, retry and selection actions.
renderSearch SearchRenderProps supplies current input value, change and optional clear callbacks, labels and query.
renderPagination PaginationRenderProps supplies one-based page, total pages and records, page size and change callbacks.
renderFooter FooterRenderProps<T> supplies apply/cancel, counts, page controls and pending-selection actions.

For custom grids, onRowSelect(row) toggles a row, not an ID array. Use selectedIds and mapper.getId(row) to derive selected state; canToggleRow accounts for already-selected rows that have become ineligible.

onSelectAll applies to eligible records in the current grid data, including the current page for paginated sources. onClearAll clears the whole draft. Grid, modal, header and footer renderers can inspect pendingSelectedIds. In a custom footer, use canConfirm and confirmationDisabledReason to present the Apply state. onClearPending removes unresolved IDs from the draft and keeps hydrated rows.

<LookupSelect
data={parts}
columns={columns}
mapper={mapper}
mode="multiple"
renderGrid={({ data, selectedIds, mapper, onRowSelect, canToggleRow }) => (
<div>
{data.map(row => (
<label key={mapper.getId(row)}>
<input
type="checkbox"
checked={selectedIds.includes(mapper.getId(row))}
disabled={canToggleRow ? !canToggleRow(row) : false}
onChange={() => onRowSelect(row)}
/>
{mapper.getText(row)}
</label>
))}
</div>
)}
/>

When replacing the modal, render the supplied header (if present) once above children. Your dialog must handle focus trapping, Escape and restoration; use a UI library’s accessible dialog component where appropriate. The custom footer must call the supplied confirmation and cancellation handlers and respect disabled confirmation.

A custom trigger should render one native button or explicitly mark the intended opener with data-lookup-select-trigger if several buttons are present. Use type="button" inside forms.