npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xsolla/xui-image

v0.106.0

Published

A cross-platform React image component with built-in aspect ratio presets and support for overlay content. Maintains consistent dimensions across different image sizes.

Downloads

8,387

Readme

Image

A cross-platform React image component with built-in aspect ratio presets and support for overlay content. Maintains consistent dimensions across different image sizes.

Installation

npm install @xsolla/xui-image
# or
yarn add @xsolla/xui-image

Demo

Basic Image

import * as React from 'react';
import { Image } from '@xsolla/xui-image';

export default function BasicImage() {
  return (
    <Image
      src="https://example.com/photo.jpg"
      alt="Sample photo"
    />
  );
}

With Aspect Ratio

import * as React from 'react';
import { Image } from '@xsolla/xui-image';

export default function RatioImage() {
  return (
    <Image
      src="https://example.com/photo.jpg"
      alt="16:9 photo"
      ratio="16:9"
      width={400}
    />
  );
}

With Border Radius

import * as React from 'react';
import { Image } from '@xsolla/xui-image';

export default function RoundedImage() {
  return (
    <Image
      src="https://example.com/photo.jpg"
      alt="Rounded photo"
      ratio="1:1"
      width={200}
      borderRadius={16}
    />
  );
}

With Overlay Slot

import * as React from 'react';
import { Image } from '@xsolla/xui-image';

export default function OverlayImage() {
  return (
    <Image
      src="https://example.com/photo.jpg"
      alt="Photo with overlay"
      ratio="16:9"
      width={400}
      slot={
        <div style={{
          background: 'rgba(0,0,0,0.5)',
          color: 'white',
          padding: 16,
          width: '100%',
          height: '100%',
          display: 'flex',
          alignItems: 'center',
          justifyContent: 'center',
        }}>
          Overlay Content
        </div>
      }
    />
  );
}

Anatomy

import { Image } from '@xsolla/xui-image';

<Image
  src="image-url.jpg"        // Image source URL
  alt="Description"          // Alt text for accessibility
  ratio="1:1"                // Aspect ratio preset
  customRatio="21 / 9"       // Custom ratio (when ratio="Custom")
  width={200}                // Container width
  borderRadius={0}           // Border radius
  slot={<Overlay />}         // Overlay content
  style={{}}                 // Container styles
  imageStyle={{}}            // Image element styles
/>

Examples

Aspect Ratio Gallery

import * as React from 'react';
import { Image } from '@xsolla/xui-image';

export default function RatioGallery() {
  const src = "https://example.com/photo.jpg";

  return (
    <div style={{ display: 'flex', gap: 16, flexWrap: 'wrap' }}>
      <div>
        <p>1:1 (Square)</p>
        <Image src={src} ratio="1:1" width={150} />
      </div>
      <div>
        <p>16:9 (Widescreen)</p>
        <Image src={src} ratio="16:9" width={200} />
      </div>
      <div>
        <p>4:3 (Standard)</p>
        <Image src={src} ratio="4:3" width={180} />
      </div>
      <div>
        <p>3:2 (Photo)</p>
        <Image src={src} ratio="3:2" width={180} />
      </div>
      <div>
        <p>2:3 (Portrait)</p>
        <Image src={src} ratio="2:3" width={120} />
      </div>
      <div>
        <p>9:16 (Story)</p>
        <Image src={src} ratio="9:16" width={100} />
      </div>
    </div>
  );
}

Custom Aspect Ratio

import * as React from 'react';
import { Image } from '@xsolla/xui-image';

export default function CustomRatioImage() {
  return (
    <Image
      src="https://example.com/ultrawide.jpg"
      alt="Ultra-wide photo"
      ratio="Custom"
      customRatio="21 / 9"
      width={400}
    />
  );
}

Placeholder State

import * as React from 'react';
import { Image } from '@xsolla/xui-image';

export default function PlaceholderImage() {
  return (
    <Image
      ratio="16:9"
      width={400}
      slot={
        <span style={{ color: '#999' }}>Loading...</span>
      }
    />
  );
}

API Reference

Image

Image Props:

| Prop | Type | Default | Description | | :--- | :--- | :------ | :---------- | | src | string | - | Image source URL. | | alt | string | "" | Alt text for accessibility. | | ratio | ImageRatio | "1:1" | Aspect ratio preset. | | customRatio | string \| number | - | Custom ratio when ratio is "Custom". | | width | number \| string | "100%" | Container width. | | borderRadius | number \| string | 0 | Border radius of container. | | slot | ReactNode | - | Overlay content (centered). | | style | CSSProperties | - | Container styles. | | imageStyle | CSSProperties | - | Image element styles. |

ImageRatio Type:

type ImageRatio =
  | "1:1"     // Square
  | "2:3"     // Portrait
  | "3:2"     // Landscape photo
  | "16:9"    // Widescreen
  | "4:3"     // Standard
  | "9:16"    // Story/mobile
  | "Custom"; // Use customRatio

Behavior

  • Image fills container with object-fit: cover
  • Background color shows when image hasn't loaded
  • Slot content overlays the image (centered)
  • Maintains aspect ratio regardless of source image dimensions

Accessibility

  • Always provide meaningful alt text
  • Decorative images can use alt=""
  • Slot content should be accessible if interactive