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

Grid Overlays

LyteNyte Grid can display overlay content over the viewport or over the rows.

Use these properties to render overlays in the grid:

  • slotViewportOverlay: Renders an overlay anchored to the viewport.
  • slotRowsOverlay: Renders an overlay anchored to the grid’s rows container.

Both properties accept a React element or a function that returns one.

Viewport Overlays

Set slotViewportOverlay to a React element to render an overlay over the entire grid. Use this for overlays that block pointer interaction, such as loading screens.

The demo below shows a loading overlay. Toggle the switch to show or hide it.

Display Loading Overlay

Fork code on stack blitzFork code on code sandbox

The loading overlay code appears below. The overlay uses absolute positioning and fills the viewport to sit above all grid content.

The grid header and rows are positioned elements with a maximum z-index of 11. Since the overlay renders inside the viewport div element, set its z-index to 12 or higher to ensure it sits on top.

<Grid
rowHeight={50}
columns={columns}
rowSource={ds}
slotViewportOverlay={
showOverlay ? (
<div className="z-12 sticky left-0 top-0 flex h-0 w-0">
<div className="bg-ln-gray-30/30 w-(--ln-vp-width) h-(--ln-vp-height) absolute left-0 top-0 flex animate-pulse items-center justify-center text-lg">
Loading...
</div>
</div>
) : null
}
/>

Row Overlay

Set the slotRowsOverlay property to a React element when you want the overlay to appear above the row content of the grid. The slotRowsOverlay element is rendered inside the grid’s rows container.

The demo below shows a rows overlay that displays a “No Rows” indicator.

No Rows Overlay

Fork code on stack blitzFork code on code sandbox

The No Rows overlay code is shown below. The overlay is a positioned element rendered inside the grid’s rows container element.

<Grid
rowHeight={50}
columns={columns}
rowSource={ds}
styles={{ viewport: { style: { overflow: "hidden" } } }}
slotRowsOverlay={
<div className="z-12 sticky left-0 top-0 flex h-0 w-0">
<div className="w-(--ln-vp-width) absolute left-0 top-0 flex flex-col items-center justify-center pt-12 text-lg">
<div className="dark:hidden">
<NoRowsSvgLight />
</div>
<div className="hidden dark:block">
<NoRowsSvgDark />
</div>
<div className="relative -top-4 text-lg font-bold">No Rows</div>
</div>
</div>
}
/>

Choosing Overlays

Use the viewport overlay for general feedback content; it is typically easier to style and implement. Use the rows overlay only if:

  • You need the overlay to extend across the full width and height of the scrollable area.
  • Your application logic requires the overlay to be rendered inside the rows container.

Next Steps

  • Viewport Shadows: Add visual depth to pinned columns and rows with scroll shadows.
  • Dialog: Present critical information or request decisions in a focused modal.
  • Menu Button: Display a list of actions or options in an accessible dropdown menu.