Avatar
hextaui/avatarFreeComponent
Shows an image or initials for a user/object.
Live preview
live · rendered by the registry
Rendered by HextaUI on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://hextaui.com/r/avatar.jsonSource
1"use client";23import * as AvatarPrimitive from "@radix-ui/react-avatar";4import * as React from "react";56import { cn } from "@/lib/utils";78const Avatar = React.forwardRef<9 React.ComponentRef<typeof AvatarPrimitive.Root>,10 React.ComponentProps<typeof AvatarPrimitive.Root>11>(function Avatar({ className, ...props }, ref) {12 return (13 <AvatarPrimitive.Root14 className={cn(15 "relative flex size-8 shrink-0 touch-manipulation overflow-hidden rounded-full focus-visible:border-ring focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",16 className17 )}18 data-slot="avatar"19 ref={ref}20 {...props}21 />22 );23});2425const AvatarImage = React.forwardRef<26 React.ComponentRef<typeof AvatarPrimitive.Image>,27 React.ComponentProps<typeof AvatarPrimitive.Image>28>(function AvatarImage(29 { className, loading, decoding, draggable, ...props },30 ref31) {32 return (33 <AvatarPrimitive.Image34 alt={(props as any).alt ?? ""}35 className={cn("aspect-square size-full", className)}36 data-slot="avatar-image"37 decoding={decoding ?? "async"}38 draggable={draggable ?? false}39 loading={loading ?? "lazy"}40 ref={ref}41 {...props}42 />43 );44});4546const AvatarFallback = React.forwardRef<47 React.ComponentRef<typeof AvatarPrimitive.Fallback>,48 React.ComponentProps<typeof AvatarPrimitive.Fallback>49>(function AvatarFallback({ className, ...props }, ref) {50 return (51 <AvatarPrimitive.Fallback52 className={cn(53 "flex size-full items-center justify-center rounded-full bg-muted",54 className55 )}56 data-slot="avatar-fallback"57 ref={ref}58 {...props}59 />60 );61});6263export { Avatar, AvatarImage, AvatarFallback };
What it pulls in
npm packages
Files it writes
More from HextaUI
All 139 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | HextaUI | Components | Free | 1 dep | |
| AI Chat Historyai-chat-history | HextaUI | Components | Free | no deps | |
| AI Citationsai-citations | HextaUI | Components | Free | no deps | |
| AI Conversationai-conversation | HextaUI | Components | Free | no deps | |
| AI Error Handlerai-error-handler | HextaUI | Components | Free | no deps | |
| AI File Uploadai-file-upload | HextaUI | Components | Free | no deps | |
| AI Messageai-message | HextaUI | Components | Free | 4 deps | |
| AI Model Selectorai-model-selector | HextaUI | Components | Free | no deps |
