Skip to content

Image

Image

Enhanced image component with lazy loading, fallback, and aspect ratio support.

Import

import { Image } from '@primitivekit/vanilla';

Basic Usage

const image = new Image({ /* options */ });
document.body.appendChild(image.element);

Props

No props available.

Customization

The Image component supports CSS variables for complete customization:

const image = new Image({
  style: {
    '--image-bg-color': '#007bff',
    '--image-text-color': '#ffffff'
  }
});

Design Tokens

The following design tokens are available for customization:

  • --image-display
  • --image-position
  • --image-overflow
  • --image-border-radius
  • --image-background
  • --image-transition-duration
  • --image-transition-timing
  • --image-width
  • --image-height
  • --image-object-fit
  • … and 38 more

Accessibility

The Image component is fully accessible and follows WCAG 2.1 AA standards:

  • ✅ Semantic HTML elements
  • ✅ Keyboard accessible
  • ✅ Focus visible indicator
  • ✅ Proper ARIA attributes
  • ✅ Screen reader compatible
  • ✅ Touch target size (44x44px minimum)
  • ✅ Color contrast compliance

Keyboard Navigation

KeyAction
TabMove focus to/from component

Related Components

  • Avatar - Component for displaying user profile images or initials in a circular or rounded container.
  • Tag - Removable label component for displaying tags, filters, or selections.
  • Table - Data display component for showing structured data in rows and columns with sorting and pagination.
  • Collapse - Component for showing and hiding content sections with expand/collapse animation.
  • Empty - Component for displaying empty states when no data or content is available.

See Also