Story Avatar
Ever wanted to create an avatar like the ones you see on Instagram Stories? This component gives you a sleek, rounded profile avatar with a gradient border effect, perfect for highlighting user stories or statuses. Easily customizable with different border styles and hover effects to match your design needs.
Preview
Follow below steps 👇🏻
Styles
Add these styles in your .css file
1@keyframes neon-flicker {20%,3100% {4opacity: 1;5box-shadow: 0 0 10px #00ffa3, 0 0 30px #00ffa3;6}750% {8opacity: 1;9box-shadow: 0 0 15px #00ffa3, 0 0 40px #00ffa3;10}11}1213.flicker {14animation: neon-flicker 0.8s infinite alternate;15}1617@keyframes spin {180% {19transform: rotate(0deg);20}21100% {22transform: rotate(360deg);23}24}2526.spin {27animation: spin 1.5s linear infinite;28}
💡 Want to increase the speed of the animation? Change the duration in the animation.
Component
Create a file story-avatar.tsx in your components folder and paste this code
1import React from 'react';23const StoryAvatar = ({4children,5spin = false, // * true value would make the background gradient spin6flicker = false, // * true value would add a neon glowing shadow flicker effect7backgroundClassName,8wrapperClassName,9className10}: {11// * Remove these data types for javascript12children?: React.ReactNode;13spin?: boolean;14flicker?: boolean;15backgroundClassName?: string;16wrapperClassName?: string;17className?: string;18// * ----19}) => {20return (21// * wrapper div22<div className={`rounded-full overflow-hidden p-[5px] flex items-center justify-center relative ${wrapperClassName} ${flicker && 'flicker'}`} >23{/* background gradient div */}24<div className={`rounded-full ${spin && 'spin'} overflow-hidden bg-gradient-to-br from-orange-400 to-pink-800 h-full w-full absolute z-0 ${backgroundClassName}`} />25{/* your component wrapper div */}26<div className={`rounded-full overflow-hidden border-[1px] border-black z-10 ${className}`}>27{children}28</div>29</div>30);31};3233export default StoryAvatar;
Usage
1<StoryAvatar spin={true} flicker={false}>2<Image alt="nft-monkey" src="/nft-monkey.svg" width={100} height={100} />3</StoryAvatar>
⭐️ Got a question or feedback?
Feel free to reach out!