8-bit Avatar
8bitcn/avatarFreeComponent
A simple 8-bit avatar component
Install it
npx shadcn@latest add https://www.8bitcn.com/r/avatar.jsonSource
1import type React from "react";2import { forwardRef } from "react";34import * as AvatarPrimitive from "@radix-ui/react-avatar";5import { cva } from "class-variance-authority";67import { cn } from "@/lib/utils";89import "@/components/ui/8bit/styles/retro.css";1011export const avatarVariants = cva("", {12 variants: {13 font: {14 normal: "",15 retro: "retro",16 },17 variant: {18 default: "",19 retro: "",20 pixel: "",21 },22 },23 defaultVariants: {24 font: "retro",25 variant: "pixel",26 },27});2829const Avatar = forwardRef<30 React.ComponentRef<typeof AvatarPrimitive.Root>,31 React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root> & {32 font?: "normal" | "retro";33 variant?: "default" | "retro" | "pixel";34 }35>(({ className = "", font, variant = "pixel", ...props }, ref) => {36 const isPixel = variant === "pixel";3738 return (39 <div className={cn("relative size-max", className)}>40 {/* Pixel frame (only show if pixel variant) */}41 {isPixel && (42 <div43 className="absolute inset-0 w-full h-full pointer-events-none"44 style={{ zIndex: 10 }}45 >46 {/* Top section - Row 1 */}47 <div className="absolute top-0 left-[23%] right-[23%] h-[7%] bg-foreground dark:bg-ring"></div>4849 {/* Top section - Row 2 */}50 <div className="absolute top-[6.25%] left-[17%] right-[17%] h-[7%] bg-foreground dark:bg-ring"></div>5152 {/* Top section - Row 3 */}53 <div className="absolute top-[12.5%] left-[11%] h-[7%] bg-foreground dark:bg-ring w-[20%]"></div>54 <div className="absolute top-[12.5%] right-[11%] h-[7%] bg-foreground dark:bg-ring w-[20%]"></div>5556 {/* Top section - Row 4 */}57 <div className="absolute top-[18.75%] left-[5%] w-[20%] h-[7%] bg-foreground dark:bg-ring"></div>58 <div className="absolute top-[18.75%] right-[5%] w-[20%] h-[7%] bg-foreground dark:bg-ring"></div>5960 {/* Top section - Row 5 */}61 <div className="absolute top-[25%] left-0 w-[20%] h-[7%] bg-foreground dark:bg-ring"></div>62 <div className="absolute top-[25%] right-0 w-[20%] h-[7%] bg-foreground dark:bg-ring"></div>6364 {/* Top section - Rows 6-7 */}65 <div className="absolute top-[31.25%] left-0 w-[13.5%] h-[13%] bg-foreground dark:bg-ring"></div>66 <div className="absolute top-[31.25%] right-0 w-[13.5%] h-[13%] bg-foreground dark:bg-ring"></div>6768 {/* Top section - Rows 8-10 */}69// … 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 Accordionaccordion | 8bitcn | Components | Free | no deps · 2 files | |
| 8-bit Alertalert | 8bitcn | Components | Free | no deps · 2 files | |
| 8-bit Alert Dialogalert-dialog | 8bitcn | Components | Free | no deps · 2 files | |
| 8-bit Badgebadge | 8bitcn | Components | Free | no deps · 2 files | |
| 8-bit Breadcrumbbreadcrumb | 8bitcn | Components | Free | no deps · 2 files | |
| 8-bit Buttonbutton | 8bitcn | Components | Free | no deps · 2 files | |
| 8-bit Button Groupbutton-group | 8bitcn | Components | Free | no deps · 4 files | |
| 8-bit Calendarcalendar | 8bitcn | Components | Free | no deps · 2 files |
