Avatar
octane/avatarFreeComponent
octane publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by octane on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://raw.githubusercontent.com/octanejs/octane/main/packages/shadcn/registry/avatar.jsonSource
1// Base UI base avatar — runs on @octanejs/base-ui's Avatar (Root/Image/Fallback), a direct2// one-to-one mapping with the radix base.3//4// `AvatarBadge`, `AvatarGroup` and `AvatarGroupCount` are plain host elements in every base —5// upstream defines no primitive for them — so they are unchanged from the radix source.6//7// Nothing here keys off a primitive-emitted attribute: the `data-[size=…]` variants read the8// `data-size` this component writes itself, and the primitive emits no state attributes at all9// (verified by rendering it — Root and Fallback are bare spans). So unlike the overlays and the10// form controls, there is no dialect to get wrong.11//12// UNVERIFIED PROVENANCE: class strings come from this package's radix base rather than13// transcribed from upstream's Base UI source.14import { Avatar as AvatarPrimitive } from '@octanejs/base-ui/avatar';1516import { cn } from '@/lib/utils';1718type Props = { className?: string } & Record<string, unknown>;1920export interface AvatarProps extends Props {21 size?: 'default' | 'sm' | 'lg';22}2324export function Avatar({ className, size = 'default', ...props }: AvatarProps) @{25 <AvatarPrimitive.Root26 data-slot="avatar"27 data-size={size}28 className={cn(29 'group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten',30 className,31 )}32 {...props}33 />34}3536export function AvatarImage({ className, ...props }: Props) @{37 <AvatarPrimitive.Image38 data-slot="avatar-image"39 className={cn('aspect-square size-full rounded-full object-cover', className)}40 {...props}41 />42}4344export function AvatarFallback({ className, ...props }: Props) @{45 <AvatarPrimitive.Fallback46 data-slot="avatar-fallback"47 className={cn(48 'flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs',49 className,50 )}51 {...props}52 />53}5455export function AvatarBadge({ className, ...props }: Props) @{56 <span57 data-slot="avatar-badge"58 className={cn(59 'absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground bg-blend-color ring-2 ring-background select-none',60 'group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden',61// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from octane
All 44 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | octane | Components | Free | 2 deps | |
| Alertalert | octane | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | octane | Components | Free | 1 dep | |
| Aspect Ratioaspect-ratio | octane | Components | Free | no deps | |
| Badgebadge | octane | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | octane | Components | Free | 1 dep | |
| Buttonbutton | octane | Components | Free | 2 deps | |
| Cardcard | octane | Components | Free | no deps |
