Client component

Image

Images with aspect ratios, captions, error fallbacks, and a built-in lightbox.

A starfield gradient
Captions wrap the image in a semantic figure.

Import#

import { Image } from "astralis-ui";
// Image.Group for galleries

Preview lightbox#

preview makes the image click-to-zoom. The lightbox supports zoom, rotate and keyboard dismissal, with arrow-key navigation inside an Image.Group.

Preview me

Click the image to preview

Error fallbacks#

BrokenBroken with custom fallback

Props#

PropTypeDefaultDescription
src / altstringNoneSource and alternative text. Both required.
aspectRatio"square" | "video" | "portrait" | "wide" | CSS ratioNoneLocks the frame to 1/1, 16/9, 3/4, 21/9, or any CSS ratio such as "4/3".
objectFit"cover" | "contain" | "fill" | "none" | "scale-down""cover"How the image fills its frame.
rounded"none" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "full""none"Corner radius.
width / heightnumber | stringNoneThe img element's intrinsic size attributes, which reserve space before it loads.
loading"lazy" | "eager""lazy"Native lazy loading.
placeholder"blur" | "empty" | URL"empty"A shimmer, nothing, or a low-resolution image shown while loading.
srcset / sizesstringNoneResponsive image sources, passed to the img element.
fallbackReactNodeiconRendered when the image fails to load.
captionReactNodeNoneWraps the image in a figure with this figcaption.
previewbooleanfalseOpens a lightbox with zoom and rotate on click.
onLoad / onError() => voidNoneFire when the image loads or fails.
ariaLabelstringNonearia-label for the img element.

Image.Group#

PropTypeDefaultDescription
items{ src, alt, caption? }[]NoneThe gallery images. Required.
columns2 | 3 | 43Grid columns.
gap"sm" | "md" | "lg""md"Space between images.
rounded"none" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "full""md"Corner radius of every image.
objectFit"cover" | "contain" | "fill" | "none" | "scale-down""cover"How every image fills its cell.

Keyboard#

With the preview lightbox open:

KeyAction
EscClose the lightbox
← / →Previous / next image (inside an Image.Group)