Resilient Image
An image that swaps to a branded fallback tile when the source fails to load.
npx shadcn@latest add https://ui.develop-better-solutions.com/r/resilient-image.jsonDependencies:
lucide-reactUsage
resilient-image-example.tsx
import { ResilientImage } from "@dbs/ui";
export default function ResilientImageExample() {
return (
<div className="flex flex-wrap gap-4">
<ResilientImage
src="https://images.unsplash.com/photo-1554147090-e1221a04a025?w=400&q=80"
alt="A working example that loads"
className="size-40 rounded-xl object-cover"
/>
<ResilientImage
src="https://example.com/this-will-404.jpg"
alt="A broken source"
fallbackLabel="Preview unavailable"
className="size-40 rounded-xl"
/>
</div>
);
}
