Vignette to soften selected edges of full-bleed imagery, custom media, or scroll-adjacent content that has no existing edge treatment. The gradients let content dissolve into the surrounding background instead of ending abruptly. Prefer a component’s built-in scrim or fading edge when available, because that component already coordinates the effect with its content and behavior.Vignette draws one independent gradient on each side. The caller controls which edges are visible and whether each visibility change animates.Vignette as a sibling of the visual content so it covers the intended area:import { Vignette, VignetteEdge } from '@wearables-ui-toolkit/mrbd';
export function MediaFrame({ photo }: { photo: Photo }) {
return (
<div className="media-frame">
<img className="media-frame-image" src={photo.src} alt={photo.description} />
<Vignette
enabledEdges={{
[VignetteEdge.TOP]: false,
[VignetteEdge.BOTTOM]: true,
[VignetteEdge.LEFT]: true,
[VignetteEdge.RIGHT]: true,
}}
/>
</div>
);
}
.media-frame {
position: relative;
overflow: hidden;
}
.media-frame-image {
width: 100%;
height: 100%;
object-fit: cover;
}
import { Vignette, VignetteEdge } from '@wearables-ui-toolkit/mrbd';
import type { VignetteEdgeVisibility } from '@wearables-ui-toolkit/mrbd';
interface ScrollFadeProps {
hasScrolledDown: boolean;
canScrollFurther: boolean;
}
export function ScrollFade({ hasScrolledDown, canScrollFurther }: ScrollFadeProps) {
const scrolledEdges: VignetteEdgeVisibility = {
[VignetteEdge.TOP]: hasScrolledDown,
[VignetteEdge.BOTTOM]: canScrollFurther,
[VignetteEdge.LEFT]: false,
[VignetteEdge.RIGHT]: false,
};
return (
<Vignette
enabledEdges={scrolledEdges}
animatedEdges={{ [VignetteEdge.LEFT]: false, [VignetteEdge.RIGHT]: false }}
/>
);
}
VignetteProps. It extends the standard div attributes and spreads every prop not listed below onto the root element. The component forwards its ref to that root.| Prop | Type | Default | Description |
|---|---|---|---|
enabledEdges | VignetteEdgeVisibility | all edges enabled | Controls which edge gradients are visible. Omitted edges remain enabled. |
animate | boolean | true | Controls whether visibility changes fade for each edge without an override. |
animatedEdges | Partial<Record<VignetteEdge, boolean>> | — | Per-edge override for animate. Omitted edges use the animate value. |
className | string | '' | Class added to the root. |
style | CSSProperties | — | Inline styles applied to the root after the component’s custom properties. |
VignetteEdge defines the four supported edge values:TOP — 'top'BOTTOM — 'bottom'LEFT — 'left'RIGHT — 'right'enabledEdges and animatedEdges. Index both maps with VignetteEdge rather than bare strings so the keys remain aligned with the public type.VignetteEdgeVisibility is Partial<Record<VignetteEdge, boolean>>. Each entry controls whether that edge is shown, and every omitted edge is shown.animatedEdges has the same shape. Its entries control whether an edge animates, and every omitted entry falls back to animate.position: relative; otherwise, the vignette resolves against a more distant ancestor and covers the wrong area.var(--uit-color-background-window) at the outer edge to var(--uit-color-background-flat), which is transparent, at the inner edge.Vignette instead follows --uit-color-background-window. Repointing that role therefore keeps the fade aligned with the surface it meets.animate sets the default for all edges, and animatedEdges overrides individual edges. This supports animated scroll-facing edges and immediate static edges. Consider animate={false} when edges never change or when the owning region already animates, avoiding competing motion.Vignette does not read the user’s motion preference. The application owns that preference and should call usePrefersReducedMotion, then pass animate={false} when reduced motion is requested. Edges then change immediately instead of crossfading.z-index so they remain visible, readable, and interactive above the vignette.aria-hidden, keeping this decorative treatment out of the accessibility tree.Vignette to darken an entire page or simulate a material.Vignette renders only its four edge gradients, so children are discarded and never appear in the DOM.