Scrim is a decorative gradient overlay that suppresses part of what is behind it so foreground text and controls stay legible over photos, video frames, or other visually busy material. It owns exactly one thing: the gradient. It does not arrange content, clip anything, size itself, or take focus.topScrim / bottomScrim and layered with CardAboveScrim and CardBelowScrim. Reach for the standalone component only for a custom media layout. It is not a window background, a panel, or a container material.import { Scrim, ScrimPosition, TextStyle, TextView } from '@wearables-ui-toolkit/mrbd';
export function PhotoCaption({ photo }: { photo: Photo }) {
return (
<div className="media-frame">
<img className="media-image" src={photo.src} alt={photo.alt} />
<Scrim position={ScrimPosition.BOTTOM} />
<TextView className="media-caption" textStyle={TextStyle.BODY1}>
{photo.caption}
</TextView>
</div>
);
}
.media-frame {
position: relative;
overflow: hidden;
}
.media-image {
width: 100%;
height: 100%;
object-fit: cover;
}
/* The scrim is positioned on its own stacking level, so a caption declared
after it still needs an explicit, higher one to paint above it. */
.media-caption {
position: absolute;
right: var(--uit-spacing-large);
bottom: var(--uit-spacing-large);
left: var(--uit-spacing-large);
z-index: 10;
}
style is merged over the computed gradient, so state can drive the scrim directly:<Scrim position={ScrimPosition.FULL} style={{ opacity: isOverlayOpen ? 1 : 0 }} />
ScrimProps. It extends the standard attributes of a div, so any other DOM attribute you pass is forwarded to the scrim element, and the component forwards its ref there too.| Prop | Type | Default | Description |
|---|---|---|---|
position | ScrimPosition | ScrimPosition.LEFT | Which gradient the scrim paints. |
className | string | '' | Class applied to the scrim element. The component ships no class of its own, so this is the only class it carries. |
style | CSSProperties | {} | Inline styles merged over the computed positioning and gradient. Anything set here wins. |
aria-hidden is always true and cannot be overridden.ScrimPosition| Member | Description |
|---|---|
LEFT | Opaque at the left edge, fading to transparent at the right. The default. |
RIGHT | Opaque at the right edge, fading to transparent at the left. |
TOP | Opaque at the top edge, fading to transparent at the bottom. |
BOTTOM | Opaque at the bottom edge, fading to transparent at the top. |
FULL | A vertical gradient that is partly transparent across the top band, ramps to fully opaque about two thirds of the way down, and stays opaque to the bottom. Use it to suppress a whole background, not to add a light wash. |
z-index to sit on top of it.style or a class of your own.opacity, inset, background, and the stacking level can all be overridden per instance without touching the component.div attributes, so children passed through them do render — but inside an aria-hidden subtree, and with pointer events off. Treat it as an empty element and put content beside it.aria-hidden="true". It has no role, no accessible name, and no keyboard behavior, so assistive technology never reaches it.BOTTOM for a caption anchored to the bottom, LEFT for a leading-edge label.Card already draws when the content is a card.style= so the scrim stays in the tree and the transition is yours to control.ScrimPosition does not provide.aria-hidden and ignores pointer events, so it cannot serve as a dismiss target.aria-hidden applies to the whole subtree, so anything you put there disappears from the accessibility tree and cannot be reached by focus navigation.overflow.