square-accordion
loading-ui/square-accordionFreeComponent
@loading-ui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by @loading-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://loading-ui.com/r/square-accordion.jsonSource
1import { cn } from "@/lib/utils";23const SQUARE_ACCORDION_BLOCKS = ["█", "▓", "▒"] as const;45type SquareAccordionProps = React.ComponentProps<"span"> & {6 blocks?: readonly string[];7 size?: number;8 track?: string;9};1011function SquareAccordion({12 className,13 blocks = SQUARE_ACCORDION_BLOCKS,14 size = 5,15 track = "░",16 style,17 ...props18}: SquareAccordionProps) {19 const cells = Math.max(2, Math.floor(size));20 const glyphs = SQUARE_ACCORDION_BLOCKS.map(21 (_, index) => blocks[index] ?? SQUARE_ACCORDION_BLOCKS[index],22 );23 const gridCells = Array.from({ length: cells * cells }, (_, index) => {24 const row = Math.floor(index / cells);25 const col = index % cells;2627 return row === 0 || row === cells - 1 || col === 0 || col === cells - 128 ? track29 : " ";30 });3132 return (33 <>34 <style>{`35 @keyframes loading-ui-square-accordion {36 0% {37 transform: translate(0, 0);38 }3940 15%,41 25% {42 transform: translate(var(--loader-x), 0);43 }4445 40%,46 50% {47 transform: translate(var(--loader-x), var(--loader-y));48 }4950 65%,51 75% {52 transform: translate(0, var(--loader-y));53 }5455 90%,56 100% {57 transform: translate(0, 0);58 }59 }60 `}</style>61 <span62 role="status"63 className={cn(64 "relative inline-flex h-[var(--loader-size)] w-[var(--loader-size)] overflow-hidden font-mono text-xl leading-none text-current select-none",65 className,66 )}67 style={68 {69 "--loader-size": `${cells}ch`,70 "--loader-x": `${cells - 1}ch`,71 "--loader-y": `${cells - 1}ch`,72 ...style,73 } as React.CSSProperties74 }75 {...props}76 >77 <span78 aria-hidden="true"79 className="pointer-events-none absolute inset-0 grid"80 style={{81 gridTemplateColumns: `repeat(${cells}, 1ch)`,82 gridTemplateRows: `repeat(${cells}, 1ch)`,83 }}84 >85 {gridCells.map((glyph, index) => (86 <span87 key={index}88 className="flex h-[1ch] w-[1ch] items-center justify-center"89 >90 {glyph}91 </span>92 ))}93 </span>94 {glyphs.map((glyph, index) => (95 <span96 key={`${glyph}-${index}`}97// … truncated
Files it writes
More from @loading-ui
All 50 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordion-loaderaccordion-loader | @loading-ui | Components | Free | no deps | |
| analyzing-imageanalyzing-image | @loading-ui | Components | Free | 1 dep | |
| arcarc | @loading-ui | Components | Free | no deps | |
| barsbars | @loading-ui | Components | Free | no deps | |
| bobbing-dotsbobbing-dots | @loading-ui | Components | Free | 1 dep | |
| bouncing-dotsbouncing-dots | @loading-ui | Components | Free | no deps | |
| classicclassic | @loading-ui | Components | Free | no deps | |
| clock-ringclock-ring | @loading-ui | Components | Free | no deps |
