Mask Gradient Y

Fades the top and bottom edges of its child, for lists that scroll.

Usage

Wrap the element that scrolls. The mask stays still while the content moves under it.

tsx
<MaskGradientY fade="2.5rem">
  <div className="h-48 overflow-y-auto rounded-margo-base border-margo border-border p-4">
    <List array={rows} itemExtractor={({ row, index }) => <p key={index}>{row}</p>} />
  </div>
</MaskGradientY>

row 1

row 2

row 3

row 4

row 5

row 6

row 7

row 8

row 9

row 10

row 11

row 12

Offset

offsetTop and offsetBottom move where the fade starts, for example below a fixed navbar.

tsx
<MaskGradientY offsetTop="var(--spacing-navbar)" fadeTop="0px" fadeBottom="1.5rem">
  <nav className="overflow-y-scroll">…</nav>
</MaskGradientY>

Reference

proptypedefault
childrenReactElement—a single element
fade?string"2rem"length of both fades at once
fadeTop?string—length of the top fade; overrides fade
fadeBottom?string—length of the bottom fade; overrides fade
offsetTop?string"0px"where the top fade starts
offsetBottom?string"0px"where the bottom fade starts, from the end