SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

ImagePlaceholder

The shared foundation for a fixed-size image-with-fallback box.

Project members
Ana BeltránAB
Ana Beltrán

Design

Luis MedinaLM
Luis Medina

Platform

Priya RamanPR
Priya Raman

Support

Everyone on the project
Ana BeltránABLuis MedinaLMPriya RamanPR+7
Luis’ avatar points at a file nothing serves, so his initials take over once the load fails — the case only a script can notice.
View code
tsx
<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.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Or copy it into your project to edit it:

Terminal
sdxc ui add image-placeholder

Usage

typescript
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.

  • ImagePlaceholder
  • ImagePlaceholder.ImageRenders the placeholder's image layer: an <img> cropped to cover, clipped to ImagePlaceholder's data-shape, its inset hairline holding the edge on a same-tone background.
  • 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 medium box matching ImagePlaceholder's size, ring and shape, its tabular digits keeping a changing count the same width.

Examples

Square with a badge

Acme
View code
tsx
<ImagePlaceholder size="lg" shape="square">
	<ImagePlaceholder.Image src={MARK} alt="Acme" />
	<ImagePlaceholder.Badge />
</ImagePlaceholder>

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeDefaultRequiredDescription
size"sm" | "md" | "lg"—NoSize variant. Defaults to DEFAULT_SIZE.
shape"circle" | "square"—NoShape variant. Defaults to DEFAULT_SHAPE.
childrenRemixNode—YesThe host's compound parts: ImagePlaceholder.Image, ImagePlaceholder.Fallback, and an optional ImagePlaceholder.Badge.

Also accepts everything in TagProps<"span">.

ImagePlaceholder.Image

PropTypeDefaultRequiredDescription
srcstring—YesImage source URL.
altstring—YesAccessible 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

PropTypeDefaultRequiredDescription
childrenRemixNode—YesFallback content, typically the subject's initials.

Also accepts everything in TagProps<"span">.

ImagePlaceholder.Badge

Also accepts everything in TagProps<"span">.

ImagePlaceholder.Group

PropTypeDefaultRequiredDescription
childrenRemixNode—YesA run of ImagePlaceholder instances, optionally trailed by ImagePlaceholder.GroupCount.

Also accepts everything in TagProps<"div">.

ImagePlaceholder.GroupCount

PropTypeDefaultRequiredDescription
shape"circle" | "square"—NoShape variant, matching the shape of the sibling placeholders it trails. Defaults to DEFAULT_SHAPE.
childrenRemixNode—YesThe overflow count text, e.g. "+3".

Also accepts everything in TagProps<"span">.

Types

NameValuesWhat 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.
@sdxc/ui

Can’t find it? Contact us