LyteNyte Grid logo for light mode. Links back to the documentation home page.
Cells

Cell Tooltips & Popovers

Use custom cell renderers to add tooltips or popovers to cells. LyteNyte Grid is unopinionated, allowing direct integration with your existing components.

Cell Tooltips

The demo below renders a Radix UI tooltip component. Hover over a cell in the Symbol column to view the symbol’s network. Use this pattern to integrate any auxiliary component into your cells.

Cell Tooltips

Fork code on stack blitzFork code on code sandbox

This implementation matches standard Radix UI documentation. LyteNyte Grid requires no wrappers or overrides, ensuring compatibility with any React tooltip component.

export function SymbolCell({ api, row }: Grid.T.CellRendererParams<GridSpec>) {
if (!api.rowIsLeaf(row) || !row.data) return null;
const ticker = row.data.symbolTicker;
const symbol = row.data.symbol;
const image = symbols[row.data.symbolTicker];
return (
<Tooltip.Root delayDuration={100}>
<Tooltip.Trigger asChild className="h-ful w-full">
<div className="grid grid-cols-[20px_auto_1fr] items-center gap-1.5">
<div>
<img
src={image}
alt={`Logo for symbol ${symbol}`}
className="h-full w-full overflow-hidden rounded-full"
/>
</div>
<div className="bg-ln-gray-20 text-ln-text-dark flex h-fit items-center justify-center rounded-lg px-2 py-px text-[10px]">
{ticker}
</div>
<div className="w-full overflow-hidden text-ellipsis">{symbol.split("/")[0]}</div>
</div>
</Tooltip.Trigger>
<Tooltip.Portal>
<Tooltip.Content className="border-ln-border-xstrong bg-ln-bg-popover z-20 grid grid-cols-[auto_20px_1fr] items-center gap-1.5 rounded-lg border p-2 text-xs">
<div className="font-bold">Network: </div>
<img
src={networks[row.data.network]}
alt={`Logo for network ${row.data.network}`}
className="h-full w-full overflow-hidden rounded-full"
/>
<div className="w-full overflow-hidden text-ellipsis">{row.data.network}</div>
</Tooltip.Content>
</Tooltip.Portal>
</Tooltip.Root>
);
}

Cell Popovers

You can also use a popover to show additional details. In the demo below, focusing a cell in the Symbol column opens a popover with the symbol’s network.

Cell Popovers

Fork code on stack blitzFork code on code sandbox

Instead of rendering the popover within a custom cell renderer, this demo renders it as a grid sibling. On cell focus, React state stores the focused cell element and network name, and the demo shows the popover when that state is set.

export default function Demo() {
const [network, setNetwork] = useState<string | null>(null);
const [anchor, setAnchor] = useState<HTMLElement | null>(null);
const ds = useClientDataSource({ data: data });
return (
<div
className="ln-grid ln-cell:text-xs ln-header:text-xs ln-header:text-ln-text-xlight"
style={{ height: 500 }}
>
<Grid
columns={columns}
columnBase={base}
rowSource={ds}
events={useMemo<Grid.Events<GridSpec>>(() => {
return {
cell: {
focus: ({ column, event, row, api }) => {
if (column.id !== "symbol" || !api.rowIsLeaf(row)) return;
setNetwork(row.data.network);
setAnchor(event.target);
},
blur: () => {
setNetwork(null);
setAnchor(null);
},
},
};
}, [])}
/>
<Popover anchor={anchor} open={!!network} modal={false} focusTrap={false} hide>
{network && (
<Popover.Container className="grid grid-cols-[20px_auto_1fr] items-center gap-1.5">
<Popover.Arrow />
<div>
<img
src={networks[network]}
alt={`Logo for network ${network}`}
className="h-full w-full overflow-hidden rounded-full"
/>
</div>
<div className="w-full overflow-hidden text-ellipsis">{network}</div>
</Popover.Container>
)}
</Popover>
</div>
);
}

To implement popovers, you can also extend the grid API with an imperative method or manage popover behavior via React context. LyteNyte Grid is unopinionated, supporting the architecture that best fits your requirements.

Info

The demo uses LyteNyte Grid’s popover component, exclusive to LyteNyte Grid PRO. You can replace it with any popover component. For details on the built-in component, see the Popover guide.

Next Steps