Loader
beui/loaderFreeComponent
Loading indicator with seventeen variants: spinner, dots, bars, dot-matrix, dither, morph, comet, scramble, metaballs, newton, helix, percent, and five terminal-style ascii spinners. Scales from one size prop, uses currentColor, and reduced-motion swaps every transform for a calm opacity pulse.
Install it
npx shadcn@latest add https://beui.dev/r/loader.jsonSource
1"use client";2// beui.dev/components/motion/loader34import { motion, useReducedMotion } from "motion/react";5import { useEffect, useId, useState } from "react";6import { EASE_IN_OUT } from "@/lib/ease";7import { cn } from "@/lib/utils";89export type LoaderVariant =10 | "spinner"11 | "dots"12 | "bars"13 | "dot-matrix"14 | "dither"15 | "ascii"16 | "ascii-line"17 | "ascii-braille"18 | "ascii-blocks"19 | "ascii-bounce"20 | "morph"21 | "comet"22 | "scramble"23 | "metaballs"24 | "newton"25 | "helix"26 | "percent";2728// Terminal-style frame sets — the loaders CLI AI agents cycle through.29const ASCII_SETS: Record<string, string[]> = {30 ascii: ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"],31 "ascii-line": ["|", "/", "-", "\\"],32 "ascii-braille": ["⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"],33 "ascii-blocks": ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█", "▇", "▆", "▅", "▄", "▃", "▂"],34 "ascii-bounce": ["⠁", "⠂", "⠄", "⡀", "⢀", "⠠", "⠐", "⠈"],35};3637export interface LoaderProps {38 /** Which animation to render. */39 variant?: LoaderVariant;40 /** Base square size in px. Everything scales from this. */41 size?: number;42 /** Seconds per animation cycle. */43 speed?: number;44 /** Accessible label announced to screen readers. */45 label?: string;46 className?: string;47}4849// Reduced motion keeps a calm opacity pulse and drops every transform.50const REDUCED = {51 animate: { opacity: [1, 0.4, 1] },52 transition: { duration: 1.4, ease: EASE_IN_OUT, repeat: Infinity },53};5455export function Loader({56 variant = "spinner",57 size = 32,58 speed = 1,59 label = "Loading",60 className,61}: LoaderProps) {62 const reduce = useReducedMotion() ?? false;6364 return (65 <span66 role="status"67 aria-label={label}68 className={cn(69 "inline-flex items-center justify-center text-foreground",70 className,71 )}72 >73 {variant === "spinner" && <Spinner size={size} speed={speed} reduce={reduce} />}74 {variant === "dots" && <Dots size={size} speed={speed} reduce={reduce} />}75 {variant === "bars" && <Bars size={size} speed={speed} reduce={reduce} />}76 {variant === "dot-matrix" && (77 <DotMatrix size={size} speed={speed} reduce={reduce} />78 )}79 {variant === "dither" && <Dither size={size} speed={speed} reduce={reduce} />}80 {ASCII_SETS[variant] && (81 <Ascii frames={ASCII_SETS[variant]} size={size} speed={speed} reduce={reduce} />82 )}83// … truncated
What it pulls in
npm packages
Files it writes
More from beui
All 104 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Action Swap Bluraction-swap-blur | beui | Components | Free | 3 deps · 4 files | |
| Action Swap Cascadeaction-swap-cascade | beui | Components | Free | 3 deps · 4 files | |
| Action Swap Rollaction-swap-roll | beui | Components | Free | 3 deps · 4 files | |
| Agent Activityagent-activity | beui | Components | Free | 4 deps · 9 files | |
| Agent Loading States Agent Progressagent-progress | beui | Components | Free | 3 deps · 3 files | |
| AI Sidebarai-sidebar | beui | Components | Free | 4 deps · 5 files | |
| Animated Badgeanimated-badge | beui | Components | Free | 4 deps · 3 files | |
| Number Animation Animated Numberanimated-number | beui | Components | Free | 3 deps · 3 files |
