BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/docs/avatar

Avatar

docs/avatar
FreeComponent

avatar component for SolidJS

Live preview

live · rendered by the registry
Rendered by docs on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://solidcn.dev/r/avatar.json

Source

components/ui/avatar.tsxsolidcn.dev/r/avatar.json
1import type { Component, JSX } from "solid-js";
2import { Show, createSignal, splitProps } from "solid-js";
3import { cn } from "~/lib/utils";
4
5const Avatar: Component<JSX.HTMLAttributes<HTMLSpanElement>> = (props) => {
6 const [local, rest] = splitProps(props, ["class"]);
7 return (
8 <span
9 class={cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", local.class)}
10 {...rest}
11 />
12 );
13};
14
15type AvatarImageProps = JSX.ImgHTMLAttributes<HTMLImageElement>;
16
17const AvatarImage: Component<AvatarImageProps> = (props) => {
18 const [local, rest] = splitProps(props, ["class", "src", "alt", "onError"]);
19 const [error, setError] = createSignal(false);
20
21 return (
22 <Show when={!error()}>
23 {/* biome-ignore lint/a11y/useAltText: alt forwarded via local.alt — callers provide meaningful text */}
24 <img
25 class={cn("aspect-square h-full w-full object-cover", local.class)}
26 src={local.src}
27 alt={local.alt ?? ""}
28 onError={(e) => {
29 setError(true);
30 if (typeof local.onError === "function") {
31 local.onError(e);
32 }
33 }}
34 {...rest}
35 />
36 </Show>
37 );
38};
39
40const AvatarFallback: Component<JSX.HTMLAttributes<HTMLSpanElement>> = (props) => {
41 const [local, rest] = splitProps(props, ["class"]);
42 return (
43 <span
44 class={cn(
45 "flex h-full w-full items-center justify-center rounded-full bg-muted text-sm font-medium",
46 local.class,
47 )}
48 {...rest}
49 />
50 );
51};
52
53export { Avatar, AvatarImage, AvatarFallback };

Facts

Registry
docs
Type
registry:ui
Access
Free
Files written
0
Licence
MIT
First indexed
2026-08-01
Last confirmed
2 days ago

Go to the source

Docs on docs solidcn.dev solidcn-ui/solidcn on GitHub Raw registry item This item as JSON

More from docs

All 44 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
AccordionaccordiondocsComponentsFreeno deps
Alert Dialogalert-dialogdocsComponentsFreeno deps
BadgebadgedocsComponentsFreeno deps
BreadcrumbbreadcrumbdocsComponentsFreeno deps
ButtonbuttondocsComponentsFreeno deps
CalendarcalendardocsComponentsFreeno deps
CardcarddocsComponentsFreeno deps
CarouselcarouseldocsComponentsFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex