Avatar
Initials avatar sizes.
import { MhAvatar } from "@/registry/new-york/items/manpowerhub-avatar/components/avatar";export function ManpowerhubAvatarBasic() { return ( <div className="flex items-center gap-2 p-4"> <MhAvatar initials="AR" size="sm" color="#6366f1" /> <MhAvatar initials="PN" size="md" color="#8b5cf6" /> <MhAvatar initials="JK" size="lg" /> </div> );}Installation
Section titled “Installation”This installation provides support for all official Shadcn icon libraries. The component is otherwise identical to the non-experimental installation.
Icon support is experimental and may not be fully stable since it uses internal Shadcn APIs.
This component relies on other items which must be installed first.
Copy and paste the following code into your project.
components/ui/mh-avatar.tsx
import * as React from "react";import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
const avatarVariants = cva( "grid shrink-0 place-items-center rounded-full font-bold text-white", { variants: { size: { xs: "size-[22px] text-[9px]", sm: "size-[26px] text-[10px]", md: "size-8 text-xs", lg: "size-10 text-[15px]", xl: "size-12 text-lg", }, }, defaultVariants: { size: "md" }, },);
export interface MhAvatarProps extends React.ComponentProps<"div">, VariantProps<typeof avatarVariants> { initials: string; color?: string;}
function MhAvatar({ className, size, initials, color = "var(--brand)", style, ...props}: MhAvatarProps) { return ( <div data-slot="mh-avatar" className={cn(avatarVariants({ size }), className)} style={{ background: color, ...style }} {...props} > {initials} </div> );}
export { MhAvatar, avatarVariants };Update the import paths to match your project setup.
Install the ManpowerHub theme first, then add this avatar:
npx shadcn@latest add @woxcn/manpowerhub-avatar