Avatar
boldkit/avatarFreeComponent
An image element with a fallback for representing the user
Live preview
live · rendered by the registry
Rendered by boldkit on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://boldkit.dev/r/avatar.jsonSource
1import * as React from 'react'2import * as AvatarPrimitive from '@radix-ui/react-avatar'3import { cn } from '@/lib/utils'45const Avatar = React.forwardRef<6 React.ElementRef<typeof AvatarPrimitive.Root>,7 React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>8>(({ className, ...props }, ref) => (9 <AvatarPrimitive.Root10 ref={ref}11 className={cn(12 'relative flex h-10 w-10 shrink-0 overflow-hidden border-3 border-foreground shadow-[4px_4px_0px_hsl(var(--shadow-color))] transition duration-200 hover:translate-x-[4px] hover:translate-y-[4px] hover:shadow-none',13 className14 )}15 {...props}16 />17))18Avatar.displayName = AvatarPrimitive.Root.displayName1920const AvatarImage = React.forwardRef<21 React.ElementRef<typeof AvatarPrimitive.Image>,22 React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>23>(({ className, ...props }, ref) => (24 <AvatarPrimitive.Image25 ref={ref}26 className={cn('aspect-square h-full w-full object-cover', className)}27 {...props}28 />29))30AvatarImage.displayName = AvatarPrimitive.Image.displayName3132const AvatarFallback = React.forwardRef<33 React.ElementRef<typeof AvatarPrimitive.Fallback>,34 React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>35>(({ className, ...props }, ref) => (36 <AvatarPrimitive.Fallback37 ref={ref}38 className={cn(39 'flex h-full w-full items-center justify-center bg-primary text-primary-foreground font-bold uppercase',40 className41 )}42 {...props}43 />44))45AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName4647export { Avatar, AvatarImage, AvatarFallback }
What it pulls in
npm packages
Other registry items
Files it writes
More from boldkit
All 94 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | boldkit | Components | Free | 2 deps | |
| Alertalert | boldkit | Components | Free | 2 deps | |
| Alert Dialogalert-dialog | boldkit | Components | Free | 1 dep | |
| ASCII Shapesascii-shapes | boldkit | Components | Free | no deps | |
| Aspect Ratioaspect-ratio | boldkit | Components | Free | 1 dep | |
| Badgebadge | boldkit | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | boldkit | Components | Free | 2 deps | |
| Buttonbutton | boldkit | Components | Free | 2 deps |
