Entity Image
mrdoge-ui/entity-imageFreeComponent
Team or region logo, unstyled; falls back to initials when the image is missing.
Install it
npx shadcn@latest add https://mrdoge.co/r/entity-image.jsonSource
1"use client"23import { useState } from "react"4import { cn } from "@/lib/utils"56export interface EntityImageProps {7 src?: string | null8 /** Used for the alt text and the initials fallback. */9 name: string10 size?: "sm" | "default" | "lg"11 className?: string12}1314const sizeClass: Record<NonNullable<EntityImageProps["size"]>, string> = {15 sm: "size-5",16 default: "size-8",17 lg: "size-10",18}1920/**21 * Just the image: no background, border, or corner radius, so team crests22 * and region flags render at their native shape. Pass a `className` (e.g.23 * `size-6`) to override the size; it takes precedence over `size`.24 */25export function EntityImage({ src, name, size = "default", className }: EntityImageProps) {26 const [errored, setErrored] = useState(false)2728 if (!src || errored) {29 return (30 <span31 className={cn(32 "flex shrink-0 items-center justify-center rounded-full bg-muted text-[0.6rem] font-medium text-muted-foreground",33 sizeClass[size],34 className35 )}36 >37 {name.slice(0, 2).toUpperCase()}38 </span>39 )40 }4142 return (43 // eslint-disable-next-line @next/next/no-img-element -- framework-agnostic registry component, no next/image dependency44 <img45 src={src}46 alt={name}47 className={cn("shrink-0 object-contain", sizeClass[size], className)}48 onError={() => setErrored(true)}49 />50 )51}
Files it writes
More from mrdoge-ui
All 26 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Bet Slipbet-slip | mrdoge-ui | Components | Free | no deps | |
| Match Cardmatch-card | mrdoge-ui | Components | Free | no deps · 3 files | |
| Match Card Compactmatch-card-compact | mrdoge-ui | Components | Free | no deps | |
| Match Highlightmatch-highlight | mrdoge-ui | Components | Free | no deps · 2 files | |
| Match Timelinematch-timeline | mrdoge-ui | Components | Free | no deps | |
| Odds Selectorodds-selector | mrdoge-ui | Components | Free | no deps · 2 files | |
| Stats Liststats-list | mrdoge-ui | Components | Free | no deps |
