import { Image } from "@senvenli/react/display";
import { Grid } from "@senvenli/react/layout";
export default function Example() {
return (
<Grid columns={3} space="space-150">
<Image src="/avatars/03.webp" alt="Marco smiling, in a blue shirt" ratio="1/1" />
<Image src="/avatars/05.webp" alt="Sofia in a white blazer" ratio="4/3" radius="large" />
<Image src="/avatars/07.webp" alt="Claire with long brown hair" ratio="16/9" radius="none" />
</Grid>
);
}import { Image } from "@senvenli/react/display";Examples
When it cannot load
A neutral tile with an icon, still named by the alt text.
import { Image } from "@senvenli/react/display";
export default function Example() {
return (
<div className="w-48">
<Image src="/missing-picture.webp" alt="The product photo" ratio="4/3" />
</div>
);
}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
ratioso 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
| Prop | Type | Default | Description |
|---|---|---|---|
srcRequired | string | – | |
altRequired | string | – | What the picture shows ("A red bicycle against a white wall"); |
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" | "cover" |
|
radius | ComponentRadius | – | |
fallback | React.ReactNode | – | Shown when the picture cannot load; a neutral tile with an image icon by default. |
loading | "lazy" | "eager" | "lazy" |
|
width | number | – | |
height | number | – |
srcRequiredstringaltRequiredstringWhat the picture shows ("A red bicycle against a white wall");
""for a purely decorative one.ratiostring | numberWidth 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;containshows all of it, with space around.radiusComponentRadiusfallbackReact.ReactNodeShown 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;eagerfor the picture above the fold.widthnumberheightnumber