Skip to main content

ShimmerView

Usage

function ShimmerViewUsage() {
return (
<View>
<ShimmerView height={140} borderRadius={20} />
<View row>
<ShimmerView circular height={60} />
<View style={{marginStart: 20, alignSelf: 'center'}}>
<ShimmerView width={200} />
<ShimmerView width={100} />
</View>
</View>
</View>
)
}

Circular Shape

function ShimmerViewCircular() {
return (
<View row>
<ShimmerView circular height={40} />
<ShimmerView
circular
height={40}
color="gold"
style={{marginHorizontal: 20}}
/>
</View>
)
}

Duration

function ShimmerViewDuration() {
return (
<View>
<ShimmerView height={40} duration={400} />
</View>
)
}

Stopping Animation

function ShimmerViewStopAnimation() {
return (
<View>
<ShimmerView height={40} animated={false} />
</View>
)
}

Control Visibility

Reset
function ShimmerViewVisibility() {
const [isLoading, setIsLoading] = useState(true)

const onReset = () => {
setIsLoading(true)
setTimeout(() => {
setIsLoading(false)
}, 2000)
}

useEffect(onReset, [])

return (
<View style={{alignSelf: 'center'}}>
<ShimmerView visible={isLoading} circular height={100}>
<Avatar
mode="circle"
size={100}
url="https://picsum.photos/200/300?random=1"
style={{marginVertical: 8}}
/>
</ShimmerView>
<Button title="Reset" size="small" onPress={onReset} />
</View>
)
}

Props

PropData TypeDefault ValueDescription
ExtendsDividerProps--Inherits properties from DividerProps
animatedbooleantrueSet it to false to disable the animation
visiblebooleantrueSet it to false to Hide the shimmer view and show it's children
circularboolean--Set it to true to have the circular shape
borderRadiusnumber--Border radius of the view
durationnumber1000Set it to false to disable the animation
widthDimensionValue100%Control Width of the divider
heightDimensionValue0.6Control height of the divider
colorstringbackground900Color of the divider
labelstring--Label inside the divider
labelPosition"left" | "right" | "center"centerLabel position where it will be rendered
rowboolean--Set true for horizontal(flexDirection) view