8-bit Loading Screen
8bitcn/loading-screenFreeBlock
A retro-styled loading screen with animated progress bar and rotating tips.
Install it
npx shadcn@latest add https://www.8bitcn.com/r/loading-screen.jsonSource
1"use client";23import { useEffect, useState } from "react";45import { cn } from "@/lib/utils";67import { Progress } from "@/components/ui/8bit/progress";89const DEFAULT_TIPS = [10 "Press any key to continue...",11 "Did you know? Saving often prevents lost progress!",12 "Tip: Explore every corner for hidden treasures.",13 "Remember to take breaks during long gaming sessions!",14 "Pro tip: Read the manual for secret moves.",15];1617export interface LoadingScreenProps extends React.ComponentProps<"div"> {18 title?: string;19 tips?: string[];20 progress?: number;21 showPercentage?: boolean;22 tipInterval?: number;23 variant?: "default" | "fullscreen";24 autoProgress?: boolean;25 autoProgressDuration?: number;26}2728export default function LoadingScreen({29 className,30 title = "LOADING",31 tips = DEFAULT_TIPS,32 progress = 0,33 showPercentage = true,34 tipInterval = 3000,35 variant = "default",36 autoProgress = false,37 autoProgressDuration = 5000,38 ...props39}: LoadingScreenProps) {40 const [currentTipIndex, setCurrentTipIndex] = useState(0);41 const [showCursor, setShowCursor] = useState(true);42 const [internalProgress, setInternalProgress] = useState(43 autoProgress ? 0 : progress44 );4546 useEffect(() => {47 if (!autoProgress) {48 setInternalProgress(progress);49 return;50 }5152 setInternalProgress(0);53 const step = 5;54 const steps = 100 / step;55 const intervalTime = autoProgressDuration / steps;5657 const timer = setInterval(() => {58 setInternalProgress((prev) => {59 const next = prev + step;60 if (next >= 100) {61 clearInterval(timer);62 return 100;63 }64 return next;65 });66 }, intervalTime);6768 return () => clearInterval(timer);69 }, [autoProgress, autoProgressDuration, progress]);7071 useEffect(() => {72 if (tips.length === 0) return;7374 const tipTimer = setInterval(() => {75 setCurrentTipIndex((prev) => (prev + 1) % tips.length);76 }, tipInterval);7778 return () => clearInterval(tipTimer);79 }, [tips, tipInterval]);8081 useEffect(() => {82 const cursorTimer = setInterval(() => {83 setShowCursor((prev) => !prev);84 }, 530);8586 return () => clearInterval(cursorTimer);87 }, []);8889 const isFullscreen = variant === "fullscreen";90 const displayProgress = autoProgress ? internalProgress : progress;9192 const content = (93 <div className="flex flex-col items-center justify-center gap-6 p-8">94 {/* Title */}95 <h296 className={cn(97// … truncated
What it pulls in
Other registry items
Files it writes
More from 8bitcn
All 121 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| 8-bit Advanced 1advanced1 | 8bitcn | Blocks | Free | no deps · 3 files | |
| 8-bit Advanced 2advanced2 | 8bitcn | Blocks | Free | no deps · 5 files | |
| 8-bit Advanced 3advanced3 | 8bitcn | Blocks | Free | no deps · 6 files | |
| 8-bit Audio Settingsaudio-settings | 8bitcn | Blocks | Free | 2 deps · 7 files | |
| 8-bit Chapter Introchapter-intro | 8bitcn | Blocks | Free | no deps · 3 files | |
| 8-bit Character Sheetcharacter-sheet | 8bitcn | Blocks | Free | no deps · 9 files | |
| 8-bit Chartchart | 8bitcn | Blocks | Free | no deps · 3 files | |
| 8-bit Chart Area Stepchart-area-step | 8bitcn | Blocks | Free | no deps · 3 files |
