You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@s-ui/react-atom-image

Package Overview
Dependencies
Maintainers
88
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@s-ui/react-atom-image

AtomImage is a component that loads an image inside, maintaining all the accesibility attributes. This component can be set to show a placeholder image, a skeleton and/or a spinner while the final image is being loaded. This component will also show an Er

2.17.0
latest
Source
npmnpm
Version published
Maintainers
88
Created
Source

AtomImage

AtomImage is a component that loads an image inside, maintaining all the accesibility attributes. This component can be set to show a placeholder image, a skeleton and/or a spinner while the final image is being loaded. This component will also show an Error Box if the image could't be loaded

documentation issue npm

Issues open NPM

Installation

$ npm install @s-ui/react-atom-image --save

Usage

After importing the component AtomImage like this

import AtomImage from '@s-ui/react-atom-image'

Basic usage

<AtomImage
  src={ urlImage }
  alt="Nice Picture"
/>

With a title

<AtomImage
  src={ urlImage }
  alt="Nice Picture"
  title="Nice Picture"
/>

With skeleton while loading

<AtomImage
  src={ urlImage }
  alt="Nice Picture"
  title="Nice Picture"
  skeleton={ urlImageSkeleton }
/>

With placeholder while loading

<AtomImage
  src={ urlImage }
  alt="Nice Picture"
  title="Nice Picture"
  placeholder={ urlImagePlaceholder }
/>

With spinner while loading

<AtomImage
  src={ urlImage }
  alt="Nice Picture"
  title="Nice picture"
  spinner={ Spinner }
/>

With custom Error if error loading

<AtomImage
  src={ urlImage }
  alt="Nice Picture"
  title="Nice picture"
  errorText="Oh no!! This image couldn't be loaded"
  errorIcon={ MyIconErrorLoading }
/>

With picture sources mdn picture

Loads 50x50 image when the viewport is under 480px, elsewise it loads a 150x150 image

<AtomImage
  src='https://via.placeholder.com/50'
  alt=''
  title=''
  sources={[
    {srcset: 'https://via.placeholder.com/150', media: '(min-width: 480px)'}
  ]}

With Web Performance attributes

Attributes to optimize image that is a LCP element, usually the first image in the viewport


import AtomImage, {DECODING, FETCHPRIORITY, LOADING} from '@s-ui/react-atom-image'

<AtomImage
  src='https://via.placeholder.com/50'
  alt='Optimized image for LCP'
  title='Optimized image for LCP'
  decoding={DECODING.sync}
  fetchpriority={FETCHPRIORITY.high}
  loading={LOADING.eager}
  sources={[
    {srcset: 'https://via.placeholder.com/150', media: '(min-width: 480px)'}
  ]}

Attributes to optimize image that is not a LCP element, usually the the images out of the viewport


import AtomImage, {DECODING, FETCHPRIORITY, LOADING} from '@s-ui/react-atom-image'

<AtomImage
  src='https://via.placeholder.com/50'
  alt='Optimized image to lazy load and low the priority'
  title='Optimized image to lazy load and low the priority'
  decoding={DECODING.async}
  fetchpriority={FETCHPRIORITY.low}
  loading={LOADING.lazy}
  sources={[
    {srcset: 'https://via.placeholder.com/150', media: '(min-width: 480px)'}
  ]}

Find full description and more examples in the demo page.

Keywords

@s-ui

FAQs

Package last updated on 03 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts