FadeMask
fade-maskFades content out to transparency toward one edge or from the center outward.
Usage
Fade out the bottom
For a bleeding showcase wall or a truncated long list: the bottom fades to transparency and works on any background.
tsx
<FadeMask direction="bottom" start="60%">
…
</FadeMask>Spotlight a texture center
direction="radial" fades outward from at: a dot or grid background that is bright at the center and recedes toward the edges.
tsx
<FadeMask direction="radial" at="30% 20%" size="50% 60%" className="absolute inset-0">
<DotPattern />
</FadeMask>When to use
Fading out the bottom of a bleeding showcase wall, spotlighting the center of a dot or grid texture, or fading both ends of a horizontal scroller. It uses a CSS mask, so it doesn't care what background sits underneath and works on cards and dark sections alike. For a blur gradient use ProgressiveBlur; for a glow use Spotlight.
Import
ts
import { FadeMask } from "@hulianui/ui"Props
| Name | Type | Default | Description |
|---|---|---|---|
| direction | "top" | "bottom" | "left" | "right" | "radial" | "bottom" | Which edge to fade toward; radial fades outward from at |
| start | string | "60%" (radial "0%") | Linear: where the fade begins (fully opaque before it). Radial: the share of the radius that stays fully opaque |
| at | string | "50% 50%" | Radial: the center of the fade |
| size | string | "50% 50%" | Radial: the extent of the fade (width height) |
Extends native<div>attributes (useclassNamefor positioning and size).
Slots
| Slot | Type | Description |
|---|---|---|
| children | ReactNode | The content to fade |
Pitfalls
- The mask applies to the whole subtree: clickable elements stay clickable even where they've faded to transparent, so keep interactive controls out of the fully transparent part.
- When wrapping an
absolute inset-0background such as DotPattern, give FadeMask its own position and size (for exampleabsolute inset-0); otherwise the background aligns to an outer positioned ancestor.
Related
Playground
<FadeMask direction="bottom">
…
</FadeMask>