Skip to main content
161

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Web docs
Data display

Image

Styles accessible images while preserving Astro, Next.js, and browser-native optimization.

FrameworksAstro · React · Elements

Registry commandlumen add Image

InteractionNative markup

01

See it and copy it

Framework example

Choose Astro, React, or Elements to compare native usage against the shared visual output. Each example assumes the framework-level setup is already complete.

AstroSame visual contract, native framework API
Lumen UI logo

Framework usage

Switch targets to compare the adapter code. The preview stays visually stable because all three packages share the same tokens and ui-* class contract.
astro
---
import { Image } from '@santi020k/lumen-astro'
---

<Image
  alt="Lumen UI logo"
  height="80"
  layout="fixed"
  src="/logo.svg"
  width="310"
/>
Edit Image in browser
02

Keep the host framework in control

Astro and Next.js optimization

Lumen owns the final image styling, including ui-image and optional dark-mode inversion. It does not run a second image pipeline. The Astro adapter delegates toastro:assets; the React adapter renders the optimizer supplied throughas and forwards its props.

Astro: import local assets

A static import supplies intrinsic dimensions and enables build-time processing. Choose layout="full-width" for viewport-width media,"constrained" for fluid media with a maximum width, or"fixed" for a fixed-size asset. Astro generates the responsivesrcset, sizes, and layout styles.

astroHeroImage.astro
---
import { Image } from '@santi020k/lumen-astro'
import hero from '../assets/hero.jpg'
---

<Image
  alt="Mountain valley at sunrise"
  layout="full-width"
  priority
  quality={80}
  src={hero}
/>
---
import { Image } from '@santi020k/lumen-astro'
import hero from '../assets/hero.jpg'
---

<Image
  alt="Mountain valley at sunrise"
  layout="full-width"
  priority
  quality={80}
  src={hero}
/>
  • Use priority only for the likely LCP image. Astro applies eager loading, high fetch priority, and synchronous decoding.
  • Public-directory and remote string sources need known dimensions. UseinferSize for an authorized remote source when its dimensions are not available, and configure remote image domains in the Astro app.
  • Override widths, sizes, quality, orformat only when the layout or delivery target calls for it.
Astro Image reference

Next.js: pass next/image through as

Passing NextImage keeps Next.js in charge of resizing, format negotiation, caching, placeholders, and preloading. With an optimizer supplied, Lumen does not inject its native loading="lazy" default.

tsxHeroImage.tsx
import NextImage from 'next/image'
import { Image as LumenImage } from '@santi020k/lumen-react'
import hero from './hero.jpg'

export function HeroImage() {
  return (
    <LumenImage
      alt="Mountain valley at sunrise"
      as={NextImage}
      placeholder="blur"
      preload
      sizes="(max-width: 768px) 100vw, 50vw"
      src={hero}
      style={{ height: 'auto', width: '100%' }}
    />
  )
}
import NextImage from 'next/image'
import { Image as LumenImage } from '@santi020k/lumen-react'
import hero from './hero.jpg'

export function HeroImage() {
  return (
    <LumenImage
      alt="Mountain valley at sunrise"
      as={NextImage}
      placeholder="blur"
      preload
      sizes="(max-width: 768px) 100vw, 50vw"
      src={hero}
      style={{ height: 'auto', width: '100%' }}
    />
  )
}
  • Static imports provide dimensions and can provide blur data automatically. String or remote sources need width and height, unlessfill is used.
  • Add an accurate sizes value for responsive or fillimages; without it the browser can select an unnecessarily large candidate.
  • In Next.js 16+, use preload for the one clear LCP image; do not combine it with loading or fetchPriority. Leave below-the-fold images on Next.js defaults.
  • Allow remote sources with narrow images.remotePatterns entries innext.config. For fill, give the parent a positioned box and a real size.
Next.js Image reference
03

Choose your target

Add this component

Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.

bash@santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
bashAstro wrapper
lumen add Image
lumen add Image

API reference

Lumen-specific props and runtime attributes for the Astro primitive. React props follow the same names; Elements use equivalent kebab-case attributes where custom elements expose them.

AttributeValuesDefaultDescription
srcImageMetadata | stringrequiredUses astro:assets in Astro; React passes the source to the native img or the optimizer supplied through as.
altstringrequiredProvides an accessible description; use an empty string for decorative images.
loading"lazy" | "eager"Astro/native img: "lazy"Defers off-screen loading. When as is set in React, Lumen leaves the optimizer default untouched unless this prop is explicit.
layout"fixed" | "constrained" | "full-width" | "none"-Astro only: generates responsive dimensions, srcset, sizes, and layout styles through astro:assets.
width, heightnumber | stringsource metadata or requiredSet intrinsic dimensions for public and remote sources. Astro and Next.js can derive them from supported static imports.
widths, sizesnumber[]; stringlayout-dependentAstro responsive controls. Next.js also uses sizes to generate and select an efficient width-based srcset.
quality, formatframework-supported valuesframework defaultPasses image encoding choices to astro:assets or to the React optimizer supplied through as.
prioritybooleanfalseAstro only: marks the likely LCP image for immediate loading, synchronous decoding, and high fetch priority.
preload, fill, placeholderNextImage propsNext.js defaultsNext.js only through as={NextImage}: keeps preloading, fill layout, and placeholder generation under next/image control.
invertOnDarkbooleanfalseInverts monochrome artwork in dark themes while preserving colorful images by default.
asReact ElementType"img"React only: renders a compatible optimizer such as next/image while retaining Lumen classes and forwarding optimizer props.
class, classNamestring""Merges custom classes with the generated ui-* root classes.
...native attributesHTML attributes-Forwards standard attributes to the root element unless the component consumes them.

Web docsFull catalog