IconWithContainerMaterial when an icon needs a material treatment rather than a bare background, such as an application identity mark or status glyph. The component draws the container material, inset icon, and material foreground layers as one non-interactive surface.import {
CornerRadius,
IconImage,
IconWithContainerMaterial,
RoundedRectangleShapeProvider,
type IconSource,
} from '@wearables-ui-toolkit/mrbd';
const CIRCLE = new RoundedRectangleShapeProvider(CornerRadius.FULL);
function StatusGlyph({ icon }: { icon: IconSource }) {
return (
<div className="status-glyph">
<IconWithContainerMaterial
shapeProvider={CIRCLE}
icon={<IconImage source={icon} />}
/>
</div>
);
}
.status-glyph {
width: var(--uit-icon-2xl);
height: var(--uit-icon-2xl);
}
color on the surface. Keep the material in useMemo so its instance remains stable across renders. Each mounted surface must own its material instance because mounting one material instance on two surfaces at the same time throws:import { useMemo } from 'react';
import type { CSSProperties } from 'react';
import {
IconImage,
IconWithContainerMaterial,
MaterialLibrary,
type IconSource,
} from '@wearables-ui-toolkit/mrbd';
const ACCENT_TINT: CSSProperties = { color: 'var(--uit-color-icon-accent)' };
function AlertGlyph({ icon }: { icon: IconSource }) {
const material = useMemo(() => MaterialLibrary.defaultWithDropShadow(), []);
return (
<div className="alert-glyph">
<IconWithContainerMaterial
material={material}
icon={<IconImage source={icon} />}
style={ACCENT_TINT}
/>
</div>
);
}
.alert-glyph {
width: var(--uit-icon-xlarge);
height: var(--uit-icon-xlarge);
}
import { IconWithContainerMaterial } from '@wearables-ui-toolkit/foundation/components/IconWithContainerMaterial';
IconWithContainerMaterialProps. It extends the standard React HTML attributes for a div. The component forwards unlisted attributes and the ref to the root element.| Prop | Type | Default | Description |
|---|---|---|---|
icon | ReactNode | — | Required. Content rendered in the centered icon slot, usually an IconImage. |
material | ContainerMaterial | MaterialLibrary.default() | Material painted behind and over the icon. |
shapeProvider | ShapeProvider | RoundedRectangleShapeProvider at CornerRadius.LARGE | Geometry used for the material’s fill and stroke paths. |
visualState | VisualState | VisualState.DEFAULT | Static state the material renders. It adds no interaction. |
padding | number | — | Pixel inset for the icon slot on all four sides, replacing the default proportional inset. Ignored when renderAtIntrinsicSize is set. |
renderAtIntrinsicSize | boolean | false | Center a fixed-size icon box instead of insetting the slot. |
intrinsicIconSize | number | 24 | Side length in pixels of that box, matching the medium icon size. Used only when renderAtIntrinsicSize is set. |
className | string | '' | Appended after the component’s own class, so a rule of equal specificity declared later wins. |
style | CSSProperties | {} | Inline styles on the root element. |
VisualState from the interaction primitives: NONE, DEFAULT, FOCUSED, PRESSED.ContainerMaterial and ShapeProvider from the material system, plus MaterialLibrary and the shape providers for building the supplied values.padding for an explicit pixel inset, or use renderAtIntrinsicSize to center a box of intrinsicIconSize without an inset. The slot centers its content, and a vector icon inside it fills the slot.material is omitted, the surface resolves MaterialLibrary.default(). The material paints behind and over the icon, so foreground layers such as strokes and glows remain above the glyph.role nor a tabindex attribute. Because the component is never focusable, it drops a passed tabIndex instead of applying it. Content scale remains constant, so the icon does not breathe with material state as content in an interactive container does.visualState renders a state without adding its interaction behavior. For example, a surface rendered with the focused visual state does not own focus.color to the primary text token so an icon painted with currentColor remains legible on the material. Set another semantic icon color token through className or style to change the tint consistently.material value makes the surface reattach the material and repaint every layer. A new shapeProvider value makes it recompute the shape path. Keep both values stable across renders for consistent performance. Each mounted surface must own a material instance because mounting one instance on two surfaces at once throws. Keep that instance in useMemo, and freely share the immutable shape provider. The parent recreates the icon element on every render regardless, so material and shape-provider stability avoid the meaningful extra work.IconImage for icon so tint and sizing follow the shared icon-slot contract.Container when the region is interactive. IconWithContainerMaterial does not provide focus, press, or click behavior.padding and renderAtIntrinsicSize; intrinsic-size rendering ignores padding.