Skip to main content

Image

Image component for displaying images with theme integration.

Basic Usage

import { Image } from '@tansuk/rott-ui';

<Image
name="LOGO"
width={100}
height={100}
/>

With Source

<Image 
source={require('./assets/photo.png')}
width={200}
height={200}
resizeMode="cover"
/>

Props

PropTypeDescription
nameImageTypesTheme image name
sourceImageSourcePropTypeImage source
widthnumberImage width
heightnumberImage height
resizeMode'cover' | 'contain' | 'stretch'Resize mode

Plus all React Native Image props.

Examples

<Image name="COMPANY_LOGO" width={120} height={40} />

Avatar

<Image 
source={{ uri: user.avatarUrl }}
width={64}
height={64}
borderRadius={32}
/>

Product Image

<Image 
source={{ uri: product.imageUrl }}
width="100%"
height={200}
resizeMode="cover"
borderRadius={12}
/>

Custom Images (Auto-Discovery)

With withRottAssets in your Metro config, images in src/assets/images/ are automatically available by filename (without extension):

// src/assets/images/cindoruk.png → name="cindoruk"
<Image name="cindoruk" width={100} height={100} />

See rott.config.ts - Asset Auto-Discovery.