ImagePlaceholder
The shared foundation for a fixed-size image-with-fallback box.
Design
Platform
Support
View code
<Header>Project members</Header>
{MEMBERS.map((member) => (
<Item key={member.id}>
<Item.Media>
<ImagePlaceholder>
<ImagePlaceholder.Image
src={member.src}
alt={member.name}
mix={[imageFallback()]}
/>
<ImagePlaceholder.Fallback>{member.initials}</ImagePlaceholder.Fallback>
{member.online ? <ImagePlaceholder.Badge /> : null}
</ImagePlaceholder>
</Item.Media>
<Item.Content>
<Item.Title>{member.name}</Item.Title>
<Item.Description>{member.role}</Item.Description>
</Item.Content>
</Item>
))}
<Header>Everyone on the project</Header>
<ImagePlaceholder.Group>
{MEMBERS.map((member) => (
<ImagePlaceholder key={member.id} size="sm">
<ImagePlaceholder.Image src={member.src} alt={member.name} mix={[imageFallback()]} />
<ImagePlaceholder.Fallback>{member.initials}</ImagePlaceholder.Fallback>
</ImagePlaceholder>
))}
<ImagePlaceholder.GroupCount>+7</ImagePlaceholder.GroupCount>
</ImagePlaceholder.Group>Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/uiimport "@sdxc/ui/theme.css";Usage
import { ImagePlaceholder } from "@sdxc/ui";Renders the placeholder host: a fixed-size, centered box whose data-shape
attribute styles it, its image, and its fallback together, leaving room
for ImagePlaceholder.Badge to sit unclipped on the corner.
Composition
The parts the component publishes, each a static property of the host.
ImagePlaceholderImagePlaceholder.ImageRenders the placeholder's image layer: an<img>cropped withobject-fit: cover, clipped to ImagePlaceholder'sdata-shape.ImagePlaceholder.FallbackRenders the placeholder's fallback layer: a<span>centering a consumer's content in uppercase text.ImagePlaceholder.BadgeRenders a small status dot pinned to the host's block-end/inline-end corner, always fully rounded regardless of ImagePlaceholder's own shape, and ringed to read as cut from whatever sits beneath it.ImagePlaceholder.GroupRenders a row of overlapping placeholders: a flex container that pulls each child back over the previous one and rings each in the neutral tint background, so the overlap reads as stacked cutouts.ImagePlaceholder.GroupCountRenders the "+N" overflow indicator trailing ImagePlaceholder.Group: a fixed medium-size box matching ImagePlaceholder's dimensions and ring treatment, taking its ownshapeprop to match the sibling placeholders.
Examples
<ImagePlaceholder size="lg" shape="square">
<ImagePlaceholder.Image src={org.logoUrl} alt={org.name} />
<ImagePlaceholder.Badge />
</ImagePlaceholder>Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Description |
|---|---|---|
size? | "sm" | "md" | "lg" | Size variant. Defaults to DEFAULT_SIZE. |
shape? | "circle" | "square" | Shape variant. Defaults to DEFAULT_SHAPE. |
children | RemixNode | The host's compound parts: ImagePlaceholder.Image, ImagePlaceholder.Fallback, and an optional ImagePlaceholder.Badge. |
Also accepts everything in TagProps<"span">.
ImagePlaceholder.Image
| Prop | Type | Description |
|---|---|---|
src | string | Image source URL. |
alt | string | Accessible text description of the image. Required, since a consumer's own localized description drives what assistive technology announces. |
Also accepts everything in Omit<
TagProps<"img">,
"src" | "alt" | "role" | "aria-label" | "aria-labelledby" | "title"
>.
ImagePlaceholder.Fallback
| Prop | Type | Description |
|---|---|---|
children | RemixNode | Fallback content, typically the subject's initials. |
Also accepts everything in TagProps<"span">.
ImagePlaceholder.Badge
Also accepts everything in TagProps<"span">.
ImagePlaceholder.Group
| Prop | Type | Description |
|---|---|---|
children | RemixNode | A run of ImagePlaceholder instances, optionally trailed by ImagePlaceholder.GroupCount. |
Also accepts everything in TagProps<"div">.
ImagePlaceholder.GroupCount
| Prop | Type | Description |
|---|---|---|
shape? | "circle" | "square" | Shape variant, matching the shape of the sibling placeholders it trails. Defaults to DEFAULT_SHAPE. |
children | RemixNode | The overflow count text, e.g. "+3". |
Also accepts everything in TagProps<"span">.
Types
| Name | Values | What it decides |
|---|---|---|
Size | "sm" | "md" | "lg" | Size variant controlling the host's rendered dimensions and, through ordinary inheritance, the fallback initials' font size. |
Shape | "circle" | "square" | Shape variant controlling the corner rounding of the host, its image, and its fallback layer: "circle" renders a fully rounded disc, and "square" renders a softly rounded square. |