Profile Picture UI
ProfilePicture (React) React wrapper for the profile picture component with type-safe props
The ProfilePicture React component is a type-safe wrapper around the <profile-picture> web component. It provides camelCase props, object prop handling, event callbacks, and SSR safety.
For the Web Component (HTML) documentation with kebab-case attributes, see ProfilePicture .
import { ProfilePicture, setCdnBaseUrl } from '@grasco/profile-picture' ;
// or
import { ProfilePicture, setCdnBaseUrl } from '@grasco/profile-picture/react' ;
Prop Type Default Description srcstring— Image source URL altstring''Alt text for accessibility extCustomerIdstring— External customer ID for CDN image loading imageMode'transparent' | 'original''original'CDN image mode
When extCustomerId is provided, the component fetches the image from the configured CDN instead of using src directly.
Preview Code
<ProfilePicture extCustomerId="demo-user-1769431807927-pd9dtmn1" alt="Kerry Nicholson" size="lg" variant="circle" />
Prop Type Default Description sizeSize | number'md'Predefined size or custom pixel value
Token Pixels 2xs20px xs24px sm32px md40px lg48px xl64px 2xl80px 3xl120px
Preview Code
<ProfilePicture extCustomerId="demo-user-1769431807927-pd9dtmn1" alt="Kerry Nicholson" size="xs" /> <ProfilePicture extCustomerId="demo-user-1769429613186-q8x65t0" alt="Sarah Chen" size="md" /> <ProfilePicture extCustomerId="demo-user-1769430228786-ompo3g1" alt="Emma Liu" size="xl" /> <ProfilePicture extCustomerId="demo-user-1769430441537-fs5i098" alt="Marcus Webb" size={120} />
Prop Type Default Description variant'circle' | 'rounded' | 'squircle' | 'square''circle'Shape variant shadow'none' | 'sm' | 'md' | 'lg' | 'glow''sm'Shadow preset
Preview Code
<ProfilePicture extCustomerId="demo-user-1769431807927-pd9dtmn1" alt="Kerry Nicholson" size="xl" variant="circle" /> <ProfilePicture extCustomerId="demo-user-1769429613186-q8x65t0" alt="Sarah Chen" size="xl" variant="rounded" /> <ProfilePicture extCustomerId="demo-user-1769430228786-ompo3g1" alt="Emma Liu" size="xl" variant="squircle" /> <ProfilePicture extCustomerId="demo-user-1769430441537-fs5i098" alt="Marcus Webb" size="xl" variant="square" />
Prop Type Default Description borderbooleanfalseEnable border borderWidth1 | 2 | 3 | 4 | 5 | 6 | 82Border width in pixels borderColorstring'#ffffff'Border color
Preview Code
<ProfilePicture extCustomerId="demo-user-1769431807927-pd9dtmn1" alt="Kerry Nicholson" size="xl" border borderWidth={2} borderColor="#ffffff" /> <ProfilePicture extCustomerId="demo-user-1769429613186-q8x65t0" alt="Sarah Chen" size="xl" border borderWidth={4} borderColor="#6366f1" /> <ProfilePicture extCustomerId="demo-user-1769430228786-ompo3g1" alt="Emma Liu" size="xl" border borderWidth={6} borderColor="#ec4899" />
Prop Type Default Description rotationnumber0Rotation angle in degrees zoomnumber1.2Zoom level (values greater than 1 zoom in)
Preview Code
<ProfilePicture extCustomerId="demo-user-1769431807927-pd9dtmn1" alt="Kerry Nicholson" size="xl" rotation={15} /> <ProfilePicture extCustomerId="demo-user-1769429613186-q8x65t0" alt="Sarah Chen" size="xl" rotation={-10} zoom={1.5} />
Prop Type Default Description bgColorstring— Background color (any valid CSS color) bgGradientstring— Background gradient (any valid CSS gradient)
These props are visible when the image has transparency or has not yet loaded.
Preview Code
<ProfilePicture extCustomerId="demo-user-1769431807927-pd9dtmn1" alt="Kerry Nicholson" size="xl" imageMode="transparent" bgColor="#6366f1" /> <ProfilePicture extCustomerId="demo-user-1769429613186-q8x65t0" alt="Sarah Chen" size="xl" imageMode="transparent" bgGradient="linear-gradient(135deg, #667eea 0%, #764ba2 100%)" />
The glow prop accepts a GlowConfig object.
Property Type Default Description colorstringborder color Glow color intensitynumber— Intensity from 0 to 1 animatebooleanfalseAnimate the glow with a pulsing effect
Preview Code
<ProfilePicture extCustomerId="demo-user-1769431807927-pd9dtmn1" alt="Kerry Nicholson" size="xl" glow={{ color: '#6366f1', intensity: 0.8 }} /> <ProfilePicture extCustomerId="demo-user-1769429613186-q8x65t0" alt="Sarah Chen" size="xl" glow={{ color: '#ec4899', intensity: 0.8, animate: true }} />
The ring prop accepts a RingConfig object.
Property Type Default Description showboolean— Show ring colorstring— Ring color gradientstring[]— Gradient colors for a multi-color ring widthnumber3Ring width in pixels gapnumber3Gap between the ring and the avatar animatebooleanfalseAnimate the ring progressnumber— Progress percentage from 0 to 100 emptyColorstring— Color for the unfilled portion of a progress ring
Preview Code
// Solid ring <ProfilePicture extCustomerId="demo-user-1769431807927-pd9dtmn1" alt="Kerry Nicholson" size="xl" ring={{ show: true, color: '#6366f1', width: 3 }} /> // Gradient ring with animation <ProfilePicture extCustomerId="demo-user-1769429613186-q8x65t0" alt="Sarah Chen" size="xl" ring={{ show: true, gradient: ['#ec4899', '#8b5cf6', '#6366f1'], animate: true }} /> // Progress ring <ProfilePicture extCustomerId="demo-user-1769430228786-ompo3g1" alt="Emma Liu" size="xl" ring={{ show: true, progress: 75, color: '#10b981', emptyColor: '#374151' }} />
The presence prop accepts a PresenceConfig object.
Property Type Default Description status'online' | 'away' | 'busy' | 'offline' | 'dnd'— Current status animatebooleanfalseShow animated ring around the indicator thickness1 | 2 | 32Ring thickness
Status Color online#30D158away#FFD60Abusy#FF453Aoffline#8E8E93dnd#FF453A
Preview Code
<ProfilePicture extCustomerId="demo-user-1769431807927-pd9dtmn1" alt="Kerry Nicholson" size="xl" presence={{ status: 'online', animate: true }} /> <ProfilePicture extCustomerId="demo-user-1769429613186-q8x65t0" alt="Sarah Chen" size="xl" presence={{ status: 'away' }} /> <ProfilePicture extCustomerId="demo-user-1769430228786-ompo3g1" alt="Emma Liu" size="xl" presence={{ status: 'busy' }} /> <ProfilePicture extCustomerId="demo-user-1769430441537-fs5i098" alt="Marcus Webb" size="xl" presence={{ status: 'dnd' }} /> <ProfilePicture extCustomerId="demo-user-1769431068241-t5mkiym" alt="Alice Spark" size="xl" presence={{ status: 'offline' }} />
The badge prop accepts a BadgeConfig object.
Property Type Default Description contentstring | number— Text, number, or leave empty for a dot positionPosition'bottom-right'Badge position colorstring— Text or icon color bgColorstring— Background color borderRadiusstring'9999px'Border radius pulsebooleanfalseEnable pulse animation glowbooleanfalseEnable glow effect maxnumber— Maximum value (displays 99+ if exceeded) iconstring— Icon before content (emoji or Unicode character)
top-left | top-center | top-right | bottom-left | bottom-center | bottom-right
Preview Code
// Notification count with pulse <ProfilePicture extCustomerId="demo-user-1769431807927-pd9dtmn1" alt="Kerry Nicholson" size="xl" badge={{ content: 5, position: 'top-right', bgColor: '#ef4444', pulse: true }} /> // Status dot <ProfilePicture extCustomerId="demo-user-1769429613186-q8x65t0" alt="Sarah Chen" size="xl" badge={{ position: 'bottom-right', bgColor: '#10b981' }} /> // With icon <ProfilePicture extCustomerId="demo-user-1769430228786-ompo3g1" alt="Emma Liu" size="xl" badge={{ icon: '✓', content: 'Verified', bgColor: '#3b82f6' }} />
Prop Type Default Description loading'lazy' | 'eager''lazy'Image loading strategy placeholder'shimmer' | 'pulse' | 'blur' | 'skeleton' | 'none''shimmer'Placeholder animation while loading placeholderColorstring'#f3f4f6'Placeholder background color
< ProfilePicture
extCustomerId = "demo-user-1769431807927-pd9dtmn1"
alt = "Kerry Nicholson"
loading = "eager"
placeholder = "blur"
placeholderColor = "#e5e7eb"
/>
Prop Type Default Description fallbackstring— Custom fallback text fallbackMode'initials' | 'gradient'— Fallback display mode
When no image is available, the component renders a fallback:
initials mode generates initials from the alt text and displays them on a colored background.
gradient mode shows a unique gradient derived from the name, providing a visually distinct placeholder for each user.
Preview Code
// Initials fallback <ProfilePicture alt="Jane Smith" size="xl" fallbackMode="initials" /> // Gradient fallback <ProfilePicture alt="Bob Wilson" size="xl" fallbackMode="gradient" /> // Custom fallback text <ProfilePicture alt="Jane Smith" size="xl" fallback="JS" fallbackMode="initials" />
The interactive prop accepts an InteractionConfig object.
Property Type Default Description hoverablebooleanfalseEnable hover effects (scale and brightness change) pressablebooleanfalseEnable press/click effects focusablebooleanfalseShow a focus ring for keyboard navigation cursor'pointer' | 'default' | 'zoom-in'— Cursor style on hover
Preview Code
<ProfilePicture extCustomerId="demo-user-1769431807927-pd9dtmn1" alt="Kerry Nicholson" size="xl" interactive={{ hoverable: true, pressable: true, cursor: 'pointer' }} onClick={(detail) => console.log('clicked', detail)} />
Prop Type Description classNamestringCSS class name styleReact.CSSPropertiesInline styles
Method Signature Description setCdnBaseUrl(url: string) => voidSet the global CDN base URL for all instances getCdnBaseUrl() => stringGet the current CDN base URL
import { setCdnBaseUrl } from '@grasco/profile-picture' ;
// The default CDN base URL is https://api.propicture.app
// Override if needed:
setCdnBaseUrl ( 'https://cdn.example.com' );
A typical avatar for a messaging app — online presence, notification badge, and clickable.
Preview Code
<ProfilePicture extCustomerId="demo-user-1769431807927-pd9dtmn1" alt="Kerry Nicholson" size="lg" presence={{ status: 'online', animate: true }} badge={{ content: 3, bgColor: '#ef4444', pulse: true }} interactive={{ hoverable: true, pressable: true, cursor: 'pointer' }} onClick={(detail) => console.log('Clicked:', detail)} />
A social-media style avatar with a gradient story ring and a bordered frame.
Preview Code
<ProfilePicture extCustomerId="demo-user-1769429613186-q8x65t0" alt="Sarah Chen" size="xl" border borderWidth={3} borderColor="#ffffff" ring={{ show: true, gradient: ['#ec4899', '#8b5cf6', '#6366f1'], animate: true }} />
A squared avatar with a verification badge — common in admin panels or marketplace profiles.
Preview Code
<ProfilePicture extCustomerId="demo-user-1769430228786-ompo3g1" alt="Emma Liu" size="xl" variant="rounded" shadow="md" badge={{ icon: '✓', bgColor: '#3b82f6', position: 'bottom-right' }} />