Avatar
aqua/avatarFreeComponent
The iChat buddy icon: photo, initials over a gel color, or the classic generic silhouette.
Live preview
live · rendered by the registry
Rendered by aqua on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://aqua.duca.dev/r/avatar.jsonSource
1import * as React from "react"2import { cva, type VariantProps } from "class-variance-authority"34import { cn } from "@/lib/utils"56const AVATAR_COLORS = [7 "#2f7de0",8 "#58b52f",9 "#e0742f",10 "#e02f6b",11 "#8a56c9",12 "#1fa8a0",13 "#7d8694",14]1516function seededColor(seed: string) {17 let hash = 018 for (let i = 0; i < seed.length; i++) {19 hash = (hash * 31 + seed.charCodeAt(i)) >>> 020 }21 return AVATAR_COLORS[hash % AVATAR_COLORS.length]22}2324function gelBackground(color: string) {25 return `linear-gradient(180deg, color-mix(in oklab, ${color} 38%, white) 0%, color-mix(in oklab, ${color} 90%, white) 50%, color-mix(in oklab, ${color} 85%, black) 51%, color-mix(in oklab, ${color} 62%, white) 100%)`26}2728const avatarVariants = cva(29 "relative inline-flex shrink-0 select-none items-center justify-center overflow-hidden border border-[#7d828c] bg-[linear-gradient(180deg,var(--aqua-gel-hi,#a8d0f7)_0%,var(--aqua-gel-mid,#4a90ec)_50%,var(--aqua-gel-deep,#2a6fd0)_51%,var(--aqua-gel-light,#6aabf3)_100%)] font-bold uppercase text-white shadow-[inset_0_1px_1px_rgba(255,255,255,0.5),0_1px_2px_rgba(20,30,50,0.25)] [text-shadow:0_-1px_1px_rgba(10,30,70,0.4)] before:pointer-events-none before:absolute before:inset-x-[2px] before:top-[1px] before:z-10 before:h-[45%] before:rounded-t-[inherit] before:bg-[linear-gradient(180deg,rgba(255,255,255,0.75),rgba(255,255,255,0.08))]",30 {31 variants: {32 size: {33 sm: "size-7 text-[10px]",34 default: "size-10 text-[13px]",35 lg: "size-16 text-lg",36 },37 shape: {38 square: "",39 circle: "rounded-full",40 },41 },42 compoundVariants: [43 { size: "sm", shape: "square", class: "rounded-[5px]" },44 { size: "default", shape: "square", class: "rounded-[7px]" },45 { size: "lg", shape: "square", class: "rounded-[10px]" },46 ],47 defaultVariants: {48 size: "default",49 shape: "square",50 },51 }52)5354function AvatarSilhouette() {55 return (56 <svg57 viewBox="0 0 24 24"58 aria-hidden="true"59 className="absolute -bottom-[8%] left-1/2 h-[88%] w-auto -translate-x-1/2 text-white/90 drop-shadow-[0_1px_1px_rgba(10,30,70,0.35)]"60 fill="currentColor"61 >62 <circle cx="12" cy="8" r="4.6" />63 <path d="M12 14.2c-4.8 0-8.4 2.8-8.4 7v2.8h16.8v-2.8c0-4.2-3.6-7-8.4-7Z" />64 </svg>65 )66}6768export type AvatarProps = React.ComponentProps<"span"> &69 VariantProps<typeof avatarVariants> & {70 src?: string71 alt?: string72 initials?: string73// … truncated
What it pulls in
npm packages
Files it writes
More from aqua
All 26 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Alertalert | aqua | Components | Free | 1 dep | |
| Badgebadge | aqua | Components | Free | 2 deps | |
| Buttonbutton | aqua | Components | Free | 2 deps | |
| Chat Bubblechat-bubble | aqua | Components | Free | no deps | |
| Checkboxcheckbox | aqua | Components | Free | 2 deps | |
| Code Blockcode-block | aqua | Components | Free | 2 deps · 2 files | |
| Cursorcursor | aqua | Components | Free | no deps | |
| Dialogdialog | aqua | Components | Free | 1 dep |
