npm.io
5.32.0 • Published 6d ago

@cleartrip/ct-design-image

Licence
ISC
Version
5.32.0
Deps
5
Size
57 kB
Vulns
0
Weekly
0

Image

An enhanced image component with loading states and optimization.


Installation

npm install @cleartrip/ct-design-image
# or
pnpm add @cleartrip/ct-design-image

Peer dependencies

# Required for all targets
npm install react

# Web only
npm install react-dom

# React Native only
npm install react-native

Usage

Basic
import { Image } from '@cleartrip/ct-design-image';

function Example() {
  return (
    <Image>
      {/* Basic usage */}
    </Image>
  );
}

Props

Prop Type Default Required Description
fallbackUrl string — No URL to swap in when src fails to load. Also used as the initial
onError (e: SyntheticEvent<HTMLImageElement, Event>) => void — No Fired when the image fails to load. The fallback swap happens
Component ComponentType<IImageWebRendererProps> — No Optional custom renderer used in place of the default <img>.
resizeMode `'contain' 'cover' 'stretch' 'center'`

Accessibility

  • The component follows accessibility best practices
  • Ensure proper ARIA attributes are provided where needed
  • Test with screen readers to ensure usability

Migration

If migrating from a previous version:

- import { Image } from 'yagami/core/components';
+ import { Image } from '@cleartrip/ct-design-image';