Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Data display

Image

Free3.9 KB gzipped

A 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

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

A dense pine forest under a green sky
Pine forest at first light.
tsx
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

BeachBeachBeach
tsx
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.

Profile banner
tsx
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>.

A sandy beach beside a calm sea
The coast at low tide.
tsx
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.

夕暮れの紫色の山々
日没直後の山並み。
tsx
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

A dense pine forest under a green sky
Pine forest at first light.
tsx
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

Image props
PropTypeDefault
altRequired

Text alternative. Required. Describe what the picture shows, or pass alt="" to mark the image decorative: it, its placeholder, and its error fallback are then hidden from assistive technology.

string—
src

Image URL. While it is undefined, the placeholder shows (useful while a URL is still being fetched). Changing it resets the loading state.

string—
srcSet

Responsive candidates, passed to the <img> as-is, e.g. "team-400.jpg 400w, team-800.jpg 800w". Pair with sizes so the browser can pick the smallest file that fills the rendered width.

string—
sizes

Rendered width hints for srcSet w descriptors, e.g. "(min-width: 768px) 50vw, 100vw".

string—
ratio

Aspect ratio of the frame, applied with CSS aspect-ratio so space is reserved before the image loads (no layout shift). A preset (square 1/1, landscape 4/3, video 16/9, wide 21/9, portrait 3/4) or a number (16 / 9). The frame then fills its container's width. Without a ratio, the frame hugs the image; pass width and height to reserve space.

ImageRatio—
fit

How the picture fills the frame (CSS object-fit). Matters when ratio or stretch sets the frame size.

"cover""contain""fill""none""scale-down""cover"
position

Which part of the picture stays in view when cropped (CSS object-position), e.g. "top" or "50% 20%".

string—
stretch

Fill the parent's width and height instead of using ratio. Use it when the parent already reserves the space. Defaults to true inside Card.Media (which sizes and clips its media), false elsewhere.

boolean—
priority

Load as soon as possible: sets loading="eager" and fetchPriority="high". Use for the main above-the-fold image only. Otherwise images load lazily (loading="lazy", decoding="async").

boolean—
placeholder

What shows while loading: skeleton, blur (needs blurDataURL), empty, or your own node.

ImagePlaceholder"skeleton"
blurDataURL

Tiny data URI (e.g. a 16px-wide preview) shown scaled and blurred when placeholder="blur".

string—
fallbackSrc

Second URL tried once if src fails.

string—
fallback

Shown when src (and fallbackSrc) fail. Defaults to a neutral surface with an image icon. It sits inside a role="img" box named by alt (hidden when alt=""), so keep it visual.

ReactNode—
radius

Corner rounding (--radius-*). Defaults to none inside Card.Media, which owns the corners.

"none""xs""sm""md""lg""xl""2xl""pill""lg"
bordered

Draw a subtle border around the frame, on top of the picture's edges.

boolean—
shadow

Soft drop shadow (--shadow-*).

"none""xs""sm""md""lg""xl""none"
caption

Caption. When set, the image is wrapped in a <figure> with a <figcaption>.

ReactNode—
onLoadingStatusChange

Called when loading starts (or restarts after src changes), finishes, or fails for good.

(status: ImageLoadingStatus) => void—
ref

The <img> element. All other native props (id, data-*, aria-*, crossOrigin, onLoad, ...) go on the <img> too; className and style go on the outer frame (or the <figure> when there's a caption).

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)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Dark mode

Score 100

35 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

Roles and states
ElementRoleStates and properties
<img>imgalt (required; alt="" for decorative)
With captionfigure<figcaption> names the figure

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery 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)
FocusFocus 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 readersNames, 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)
ColorMeaning 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 reflowAt 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 targetsClick 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)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)