メインコンテンツまでスキップ

Fade

Every example on this page is live, drawn by the library's Storybook, where you can also change its props and see the result.

Dithered transparent-to-background transition using 4×4 Bayer ordered dithering. Avoids visible banding from CSS gradients. Common use case: placing at the edge of a content area to indicate overflow.

Every pixel it draws is the background at full ink, so it is the way to fade content out on the frame, where an opacity-* would turn the text grey.

The last band is solid background, so the fade ends with nothing of the content showing through, even when a preview draws it scaled.

The Fade SVG is absolutely positioned with pointer-events: none, so it occupies zero space in the layout flow. Place it inside a position: relative container to anchor it to the desired edge.

Import​

import { Fade } from "~lib/layout/fade";

Props​

NameTypeRequiredDefaultDescription
direction"to-top" | "to-bottom" | "to-left" | "to-right"No"to-bottom"Fade direction
sizenumberNo40Thickness of fade in px

Examples​

Default (to-bottom)​

StorybookでDefaultを開く

To Top​

StorybookでTo Topを開く

To Left​

StorybookでTo Leftを開く

To Right​

StorybookでTo Rightを開く

Large Size​

StorybookでLarge Sizeを開く

See Also​

  • Brim - A box that clips its content and draws this fade only when something is cut off
  • Divider - Horizontal/vertical separator
  • Card - Bordered container