diff --git a/apps/web/components/ComponentPagePreview.tsx b/apps/web/components/ComponentPagePreview.tsx
index 6d96facb..e14b33d5 100644
--- a/apps/web/components/ComponentPagePreview.tsx
+++ b/apps/web/components/ComponentPagePreview.tsx
@@ -146,6 +146,9 @@ export function ComponentPagePreview({
demoComponentFile ?? mainComponentFile ?? "",
)
+ const [previewError, setPreviewError] = useState(false)
+ const [isLoading, setIsLoading] = useState(true)
+
if (!css)
return (
@@ -209,13 +212,40 @@ export function ComponentPagePreview({
className="flex-grow h-full relative"
transition={{ duration: 0.3 }}
>
-
}>
-
+
}>
+ {previewError ? (
+
+
+ Failed to load preview
+
+
+
+ ) : (
+
setIsLoading(false)}
+ onError={() => {
+ setPreviewError(true)
+ setIsLoading(false)
+ }}
+ />
+ )}
+ {isLoading && (
+
+
+
+ )}
diff --git a/apps/web/components/LoadingSpinner.tsx b/apps/web/components/LoadingSpinner.tsx
index 9860bac8..b007419b 100644
--- a/apps/web/components/LoadingSpinner.tsx
+++ b/apps/web/components/LoadingSpinner.tsx
@@ -1,10 +1,10 @@
-export const LoadingSpinner = () => (
+export const LoadingSpinner = ({ text = "Loading..." }: { text?: string }) => (
)