Skip to content
SENVENLI UI

Image

A picture in a box that keeps its shape while it loads, with a fallback when it cannot load.
A fixed shape
import { Image } from "@senvenli/react/display";

Examples

When it cannot load

A neutral tile with an icon, still named by the alt text.
The product photo

Guidelines

When to use it

  • A product photo, a cover, a thumbnail in a card.

Use something else when

  • The picture is of a person or a company. Avatar
  • Several pictures to page through. Carousel
  • A picture to open full screen. Image viewer

Do and avoid

  • Give ratio so the page does not jump while the picture loads.

Accessibility

Built in

  • Loads lazily by default.
  • The fallback keeps the alt text as its name.

You provide

  • An alt text that says what the picture shows, or "" for decoration.

API reference

Image

srcRequired
string
altRequired
string

What the picture shows ("A red bicycle against a white wall"); "" for a purely decorative one.

ratio
string | number

Width to height ("16/9", "4/3", "1/1", or a number like 1.5): the box keeps it before the picture loads, so the page never jumps. Left out, the picture's own shape.

fit
"cover" | "contain"Default "cover"

cover (default) fills the box and crops; contain shows all of it, with space around.

radius
ComponentRadius
fallback
React.ReactNode

Shown when the picture cannot load; a neutral tile with an image icon by default.

loading
"lazy" | "eager"Default "lazy"

lazy (default) loads it when it nears the screen; eager for the picture above the fold.

width
number
height
number