Avatar
basecn/avatarFreeComponent
An easily stylable avatar component.
Live preview
live · rendered by the registry
Rendered by basecn on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://basecn.dev/r/avatar.jsonSource
1import { cn } from "@/lib/utils";2import { Avatar as AvatarPrimitive } from "@base-ui/react/avatar";34function Avatar({ className, ...props }: AvatarPrimitive.Root.Props) {5 return (6 <AvatarPrimitive.Root7 data-slot="avatar"8 className={cn(9 "relative flex size-8 shrink-0 overflow-hidden rounded-full",10 className11 )}12 {...props}13 />14 );15}1617function AvatarImage({ className, ...props }: AvatarPrimitive.Image.Props) {18 return (19 <AvatarPrimitive.Image20 data-slot="avatar-image"21 className={cn("aspect-square size-full", className)}22 {...props}23 />24 );25}2627function AvatarFallback({28 className,29 ...props30}: AvatarPrimitive.Fallback.Props) {31 return (32 <AvatarPrimitive.Fallback33 data-slot="avatar-fallback"34 className={cn(35 "bg-muted flex items-center justify-center size-full rounded-full text-sm",36 className37 )}38 {...props}39 />40 );41}4243export { Avatar, AvatarImage, AvatarFallback };
What it pulls in
npm packages
Files it writes
More from basecn
All 56 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | basecn | Components | Free | 2 deps | |
| Alertalert | basecn | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | basecn | Components | Free | 1 dep | |
| Aspect Ratioaspect-ratio | basecn | Components | Free | no deps | |
| Autocompleteautocomplete | basecn | Components | Free | 2 deps | |
| Badgebadge | basecn | Components | Free | 2 deps | |
| Breadcrumbbreadcrumb | basecn | Components | Free | 2 deps | |
| Buttonbutton | basecn | Components | Free | 2 deps |
