avatar
shadcn-solidjs/avatarFreeComponent
shadcn-solidjs publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by shadcn-solidjs on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://shadcn-solidjs.com/r/avatar.jsonSource
1import * as ImagePrimitive from "@kobalte/core/image";2import type { PolymorphicProps } from "@kobalte/core/polymorphic";34import { cn } from "~/lib/utils.ts";5import type { Component, ComponentProps, ValidComponent } from "solid-js";67import { splitProps } from "solid-js";89type AvatarRootProps<T extends ValidComponent = "span"> =10 & ImagePrimitive.ImageRootProps<T>11 & {12 class?: string | undefined;13 size?: "default" | "sm" | "lg";14 };1516const Avatar = <T extends ValidComponent = "span">(17 props: PolymorphicProps<T, AvatarRootProps<T>>,18) => {19 const [local, others] = splitProps(props as AvatarRootProps, [20 "class",21 "size",22 ]);23 return (24 <ImagePrimitive.Root25 data-slot="avatar"26 data-size={local.size ?? "default"}27 class={cn(28 "size-8 rounded-full after:rounded-full data-[size=lg]:size-10 data-[size=sm]:size-6 group/avatar relative flex shrink-0 select-none after:absolute after:inset-0 after:border after:border-border after:mix-blend-darken dark:after:mix-blend-lighten",29 local.class,30 )}31 {...others}32 />33 );34};3536type AvatarImageProps<T extends ValidComponent = "img"> =37 & ImagePrimitive.ImageImgProps<T>38 & {39 class?: string | undefined;40 };4142const AvatarImage = <T extends ValidComponent = "img">(43 props: PolymorphicProps<T, AvatarImageProps<T>>,44) => {45 const [local, others] = splitProps(props as AvatarImageProps, ["class"]);46 return (47 <ImagePrimitive.Img48 data-slot="avatar-image"49 class={cn(50 "rounded-full aspect-square size-full object-cover",51 local.class,52 )}53 {...others}54 />55 );56};5758type AvatarFallbackProps<T extends ValidComponent = "span"> =59 & ImagePrimitive.ImageFallbackProps<T>60 & { class?: string | undefined };6162const AvatarFallback = <T extends ValidComponent = "span">(63 props: PolymorphicProps<T, AvatarFallbackProps<T>>,64) => {65 const [local, others] = splitProps(props as AvatarFallbackProps, ["class"]);66 return (67 <ImagePrimitive.Fallback68 data-slot="avatar-fallback"69 class={cn(70 "bg-muted text-muted-foreground rounded-full flex size-full items-center justify-center text-sm group-data-[size=sm]/avatar:text-xs",71 local.class,72 )}73 {...others}74 />75 );76};7778const AvatarBadge: Component<ComponentProps<"span">> = (props) => {79 const [local, others] = splitProps(props, ["class"]);80 return (81 <span82 data-slot="avatar-badge"83 class={cn(84// … truncated
What it pulls in
npm packages
More from shadcn-solidjs
All 85 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | shadcn-solidjs | Components | Free | 1 dep | |
| alertalert | shadcn-solidjs | Components | Free | 2 deps | |
| alert-dialogalert-dialog | shadcn-solidjs | Components | Free | 2 deps | |
| aspect-ratioaspect-ratio | shadcn-solidjs | Components | Free | no deps | |
| attachmentattachment | shadcn-solidjs | Components | Free | 2 deps | |
| badgebadge | shadcn-solidjs | Components | Free | 2 deps | |
| breadcrumbbreadcrumb | shadcn-solidjs | Components | Free | 1 dep | |
| bubblebubble | shadcn-solidjs | Components | Free | 2 deps |
