Viewport Shadows
Use the viewport shadows slot to render shadows for pinned sections and add visual depth.
Shadows Slot
LyteNyte Grid exports ViewportShadows. Pass it to slotShadows on the
grid. ViewportShadows renders within the grid’s viewport element.
The demo below demonstrates ViewportShadows. The pinned sections show borders.
Scroll horizontally or vertically to observe shadows appearing.
The code for the viewport shadows is shown below. Note that the slotShadows property
must be provided a component function and does not accept a React Element.
<Grid rowHeight={50} columns={columns} rowSource={ds} slotShadows={ViewportShadows} />The ViewportShadows component uses CSS to remain visible regardless of the grid’s
scroll position. This behavior makes the component useful for drawing pin area
shadows. The shadows also avoid CSS stacking issues, which makes the component well
suited for adding visual depth without shadows being clipped.
Styling Viewport Shadows
LyteNyte Grid components are unstyled by default. The ViewportShadows component
requires custom CSS to display visual feedback. If you are using a
prebuilt LyteNyte Grid theme, the required styles are already applied.
To style or adjust the ViewportShadows component, target its data attributes.
The CSS used by the prebuilt themes is shown below and can be used as a reference
for custom styling.
The data-ln-y-status and data-ln-x-status data attributes have one of the following values:
"none": Set when the grid has no scroll applied.xrepresents horizontal scroll andyrepresents vertical scroll."partial": Set when some scroll has been applied to the grid."full": Set when the grid is fully scrolled in the direction.xrepresents horizontal scroll andyrepresents vertical scroll.
[data-ln-viewport="true"] { & [data-ln-start-shadow], & [data-ln-end-shadow] { width: 5px; opacity: 0; transition: opacity 200ms ease-in-out; pointer-events: none; }
& [data-ln-top-shadow], & [data-ln-bottom-shadow] { height: 8px; opacity: 1; transition: opacity 200ms ease-in-out; pointer-events: none; }
& [data-ln-end-shadow] { transform: translateX(-5px); }
&[data-ln-y-status="full"] [data-ln-top-shadow], &[data-ln-y-status="partial"] [data-ln-top-shadow] { opacity: 1; background-image: linear-gradient(to bottom, var(--ln-border), transparent); } &[data-ln-y-status="none"] [data-ln-bottom-shadow], &[data-ln-y-status="partial"] [data-ln-bottom-shadow] { opacity: 1; background-image: linear-gradient(to top, var(--ln-border), transparent); transform: translateY(-8px); }
&[data-ln-x-status="full"] [data-ln-start-shadow], &[data-ln-x-status="partial"] [data-ln-start-shadow] { opacity: 1; background-image: linear-gradient(to right, var(--ln-border), transparent); }
&[data-ln-x-status="none"] [data-ln-end-shadow], &[data-ln-x-status="partial"] [data-ln-end-shadow] { opacity: 1; background-image: linear-gradient(to left, var(--ln-border-strong) 0, transparent); }}Shadows Properties
The ViewportShadows component accepts the properties listed below. To apply these
properties, create an intermediate component. For example:
function MyShadows() { return <ViewportShadows start={false} />;}
<Grid rowHeight={50} columns={columns} rowSource={ds} slotShadows={MyShadows} />;Prop
Next Steps
- Grid Overlays: LyteNyte Grid can display overlay content over the viewport or over the rows.
- Smart Select: Streamline data selection using a versatile combobox or select element.
- Pill Manager: Create and manage grid interactions using label pills.
