Skip to main content

Placeholders

Show loading states while icons are being fetched from the Iconify API.

Built-in Presetsโ€‹

rn-iconify includes three built-in placeholder presets:

import { Mdi } from 'rn-iconify';

// Skeleton - Simple gray box
<Mdi name="home" placeholder="skeleton" />

// Pulse - Fading animation
<Mdi name="home" placeholder="pulse" />

// Shimmer - Gradient sweep effect
<Mdi name="home" placeholder="shimmer" />

Preset Comparisonโ€‹

PresetAnimationUse Case
skeletonNoneSimple, minimal UI
pulseFade in/outSubtle loading indicator
shimmerGradient sweepPremium feel, content loading

Custom Placeholdersโ€‹

Use any React Native component as a placeholder:

import { Mdi } from 'rn-iconify';
import { ActivityIndicator, View, Text } from 'react-native';

// Activity Indicator
<Mdi
name="home"
size={24}
placeholder={<ActivityIndicator size="small" color="blue" />}
/>

// Custom View
<Mdi
name="home"
size={48}
placeholder={
<View style={{ width: 48, height: 48, backgroundColor: '#e0e0e0', borderRadius: 8 }} />
}
/>

// Text placeholder
<Mdi
name="home"
size={24}
placeholder={<Text>...</Text>}
/>

Global Placeholder with Theme Providerโ€‹

Set a default placeholder for all icons:

import { IconThemeProvider, Mdi } from 'rn-iconify';

function App() {
return (
<IconThemeProvider
theme={{
placeholder: 'shimmer',
}}
>
{/* All icons will use shimmer placeholder */}
<Mdi name="home" />
<Mdi name="settings" />
</IconThemeProvider>
);
}

Custom Global Placeholderโ€‹

import { IconThemeProvider, Mdi } from 'rn-iconify';
import { ActivityIndicator } from 'react-native';

function App() {
return (
<IconThemeProvider
theme={{
placeholder: <ActivityIndicator size="small" />,
}}
>
<Mdi name="home" />
</IconThemeProvider>
);
}

Placeholder Sizingโ€‹

Placeholders automatically inherit the icon's size:

// Placeholder will be 48x48
<Mdi name="home" size={48} placeholder="skeleton" />

// Placeholder will be 24x24 (default)
<Mdi name="home" placeholder="skeleton" />

Conditional Placeholdersโ€‹

Show different placeholders based on context:

import { Mdi } from 'rn-iconify';
import { Platform } from 'react-native';

function Icon({ name }: { name: string }) {
const placeholder = Platform.OS === 'ios' ? 'shimmer' : 'skeleton';

return <Mdi name={name} placeholder={placeholder} />;
}

Performance Considerationsโ€‹

  • First render: Placeholder shows while icon fetches from API
  • Cached icons: No placeholder shown (instant render)
  • Prefetched icons: No placeholder shown

To eliminate placeholders entirely, use:

Disable Placeholdersโ€‹

To show nothing while loading:

<Mdi name="home" placeholder={null} />

Component API Referenceโ€‹

Skeletonโ€‹

Static gray box placeholder (no animation).

import { Skeleton } from 'rn-iconify';

<Skeleton width={24} height={24} />
<Skeleton width={48} height={48} color="#D1D5DB" borderRadius={8} />

Pulseโ€‹

Fading opacity animation placeholder.

import { Pulse } from 'rn-iconify';

<Pulse width={24} height={24} />
<Pulse width={32} height={32} duration={1500} color="#E5E7EB" />

Shimmerโ€‹

Gradient sweep animation placeholder.

import { Shimmer } from 'rn-iconify';

<Shimmer width={24} height={24} />
<Shimmer
width={48}
height={48}
color="#E5E7EB"
highlightColor="#F9FAFB"
duration={1200}
/>

PlaceholderPropsโ€‹

Common props for Skeleton, Pulse, and Shimmer components.

PropTypeDefaultDescription
widthnumberrequiredWidth of the placeholder
heightnumberrequiredHeight of the placeholder
colorstring'#E1E1E1'Background color
highlightColorstring'#F5F5F5'Secondary color (shimmer gradient)
durationnumber1000Animation duration in milliseconds
borderRadiusnumber4Border radius
testIDstring-Test ID for testing

PlaceholderFactoryโ€‹

Creates the appropriate placeholder based on type.

import { PlaceholderFactory } from 'rn-iconify';

// Using preset
<PlaceholderFactory type="shimmer" width={24} height={24} />

// Using custom component
<PlaceholderFactory
type={<ActivityIndicator size="small" />}
width={24}
height={24}
/>

PlaceholderFactoryPropsโ€‹

PropTypeDefaultDescription
typePlaceholderTyperequired'skeleton' | 'pulse' | 'shimmer' | ReactNode
widthnumberrequiredWidth of the placeholder
heightnumberrequiredHeight of the placeholder
colorstring'#E1E1E1'Background color
highlightColorstring'#F5F5F5'Secondary color for shimmer
durationnumber1000Animation duration in milliseconds
borderRadiusnumber4Border radius
testIDstring-Test ID for testing

Next Stepsโ€‹