Data display
Image
Free3.9 KB gzippedA native <img> in a frame that reserves its aspect ratio, shows a placeholder while loading, fades the picture in, and falls back gracefully on errors (fallbackSrc, then a fallback box that keeps the alt text as its accessible name).
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · No keyboard interaction of its own · Full report
Import
import { Image } from "@vjdesigns/vjdesigns-ui";
Importing only Image adds about 3.9 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Ratio and caption
ratio reserves space before the image loads, so the layout doesn't jump. A skeleton shows while it loads.
import { Image } from "@vjdesigns/vjdesigns-ui";
export function RatioAndCaption() {
return (
<div style={{ width: "100%", maxWidth: "30rem" }}>
<Image src="/docs/forest.svg" alt="A dense pine forest under a green sky" ratio="video" caption="Pine forest at first light." shadow="md" />
</div>
);
}
Ratios
import { Grid, Image } from "@vjdesigns/vjdesigns-ui";
export function Ratios() {
return (
<Grid columns={3} gap={3} style={{ width: "100%" }} align="start">
<Image src="/docs/coast.svg" alt="Beach" ratio="square" />
<Image src="/docs/coast.svg" alt="Beach" ratio="landscape" />
<Image src="/docs/coast.svg" alt="Beach" ratio="portrait" />
</Grid>
);
}
Fallback
This image's file doesn't exist, so a fallback shows in its place. Pass fallbackSrc to try another image first, or fallback for custom content.

import { Image } from "@vjdesigns/vjdesigns-ui";
export function Fallback() {
return (
<div style={{ width: "100%", maxWidth: "16rem" }}>
<Image src="/docs/missing-photo.jpg" alt="Profile banner" ratio="landscape" bordered />
</div>
);
}
Accessibility
alt is required: describe what the picture shows, or pass alt="" when it's purely decorative, which also hides its placeholder and error fallback from assistive technology. caption wraps the image in a <figure> with a <figcaption>.
import { Grid, Image } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
return (
<Grid columns={{ base: 1, sm: 2 }} gap={4} style={{ width: "100%" }}>
<Image src="/docs/coast.svg" alt="A sandy beach beside a calm sea" ratio="landscape" caption="The coast at low tide." />
<Image src="/docs/forest.svg" alt="" ratio="landscape" />
</Grid>
);
}
Translated
Alt text and captions are your own content, so translate them with the rest of the page. LocaleProvider sets lang, so they're read in Japanese.
import { Image, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ja from "@vjdesigns/vjdesigns-ui/locales/ja";
export function Translated() {
return (
<LocaleProvider locale="ja" messages={ja}>
<div style={{ width: "100%", maxWidth: "26rem" }}>
<Image src="/docs/mountains.svg" alt="夕暮れの紫色の山々" ratio="landscape" caption="日没直後の山並み。" />
</div>
</LocaleProvider>
);
}
Right to left
The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.
Ratio and caption
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
// RatioAndCaption is the "Ratio and caption" example above.
<LocaleProvider locale="ar" messages={ar}>
<RatioAndCaption />
</LocaleProvider>
API reference
Image
| Prop | Type | Default |
|---|---|---|
altRequiredText alternative. Required. Describe what the picture shows, or pass | string | — |
srcImage URL. While it is | string | — |
srcSetResponsive candidates, passed to the | string | — |
sizesRendered width hints for | string | — |
ratioAspect ratio of the frame, applied with CSS | ImageRatio | — |
fitHow the picture fills the frame (CSS | "cover""contain""fill""none""scale-down" | "cover" |
positionWhich part of the picture stays in view when cropped (CSS | string | — |
stretchFill the parent's width and height instead of using | boolean | — |
priorityLoad as soon as possible: sets | boolean | — |
placeholderWhat shows while loading: | ImagePlaceholder | "skeleton" |
blurDataURLTiny data URI (e.g. a 16px-wide preview) shown scaled and blurred when | string | — |
fallbackSrcSecond URL tried once if | string | — |
fallbackShown when | ReactNode | — |
radiusCorner rounding ( | "none""xs""sm""md""lg""xl""2xl""pill" | "lg" |
borderedDraw a subtle border around the frame, on top of the picture's edges. | boolean | — |
shadowSoft drop shadow ( | "none""xs""sm""md""lg""xl" | "none" |
captionCaption. When set, the image is wrapped in a | ReactNode | — |
onLoadingStatusChangeCalled when loading starts (or restarts after | (status: ImageLoadingStatus) => void | — |
refThe | Ref<HTMLImageElement> | — |
Also accepts native <img> attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
Image targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Dark mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
Not focusable, so there's no keyboard interaction of its own.
Roles and states
| Element | Role | States and properties |
|---|---|---|
<img> | img | alt (required; alt="" for decorative) |
With caption | figure | <figcaption> names the figure |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |