Avatar
scrollxui/avatarFreeComponent
Customizable Avatar component with animated borders for status indicators like "close friends" or "normal story".
Live preview
live · rendered by the registry
Rendered by scrollxui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://scrollxui.dev/registry/avatar.jsonSource
1'use client';23import * as React from 'react';4import * as AvatarPrimitive from '@radix-ui/react-avatar';5import { cn } from '@/lib/utils';67type AvatarProps = React.ComponentPropsWithoutRef<8 typeof AvatarPrimitive.Root9> & {10 variant?: 'close-friends' | 'normal' | 'none';11};1213const Avatar = React.forwardRef<14 React.ComponentRef<typeof AvatarPrimitive.Root>,15 AvatarProps16>(({ className, variant = 'none', ...props }, ref) => {17 const ringClass =18 variant === 'close-friends'19 ? 'bg-linear-to-tr from-green-400 to-green-600'20 : variant === 'normal'21 ? 'bg-[conic-gradient(at_top_right,#f09433,#e6683c,#dc2743,#cc2366,#bc1888,#f09433)]'22 : '';2324 return variant === 'none' ? (25 <AvatarPrimitive.Root26 ref={ref}27 className={cn(28 'relative flex h-12 w-12 shrink-0 overflow-hidden rounded-full',29 className,30 )}31 {...props}32 />33 ) : (34 <div35 className={cn(36 'h-14 w-14 rounded-full p-0.5',37 ringClass,38 'flex items-center justify-center',39 )}40 >41 <div className='h-full w-full rounded-full bg-black flex items-center justify-center overflow-hidden'>42 <AvatarPrimitive.Root43 ref={ref}44 className={cn(45 'h-full w-full rounded-full overflow-hidden',46 className,47 )}48 {...props}49 />50 </div>51 </div>52 );53});54Avatar.displayName = AvatarPrimitive.Root.displayName;5556const AvatarImage = React.forwardRef<57 React.ComponentRef<typeof AvatarPrimitive.Image>,58 React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>59>(({ className, ...props }, ref) => (60 <AvatarPrimitive.Image61 ref={ref}62 className={cn('h-full w-full object-cover not-prose', className)}63 {...props}64 />65));66AvatarImage.displayName = AvatarPrimitive.Image.displayName;6768const AvatarFallback = React.forwardRef<69 React.ComponentRef<typeof AvatarPrimitive.Fallback>,70 React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>71>(({ className, ...props }, ref) => (72 <AvatarPrimitive.Fallback73 ref={ref}74 className={cn(75 'flex h-full w-full items-center justify-center rounded-full bg-muted text-sm font-medium',76 className,77 )}78 {...props}79 />80));81AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;8283export { Avatar, AvatarImage, AvatarFallback };
What it pulls in
npm packages
Other registry items
Files it writes
More from scrollxui
All 180 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | scrollxui | Components | Free | 4 deps | |
| Alert Dialogalert-dialog | scrollxui | Components | Free | 7 deps | |
| Animated Buttonanimated-button | scrollxui | Components | Free | 4 deps | |
| Animated Tabsanimated-tabs | scrollxui | Components | Free | 1 dep | |
| Animated Testimonialsanimated-testimonials | scrollxui | Components | Free | 2 deps | |
| Animated TextGenerateanimated-textgenerate | scrollxui | Components | Free | 3 deps | |
| Announcementannouncement | scrollxui | Components | Free | 5 deps | |
| Aspect Ratioaspect-ratio | scrollxui | Components | Free | 1 dep |
