Glass Gauge
einui/glass-gaugeFreeComponent
A gauge component with glass morphism styling, suitable for displaying progress or performance metrics.
Live preview
live · rendered by the registry
Rendered by einui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.eindev.ir/r/glass-gauge.jsonSource
1"use client"23import * as React from "react"4import { cn } from "@/lib/utils"56interface GlassGaugeProps extends React.HTMLAttributes<HTMLDivElement> {7 value: number8 max?: number9 size?: "sm" | "md" | "lg"10 showValue?: boolean11 label?: string12 colorScheme?: "cyan" | "purple" | "green" | "orange" | "gradient"13 animated?: boolean14}1516const sizes = {17 sm: { size: 100, strokeWidth: 8, fontSize: "text-lg" },18 md: { size: 150, strokeWidth: 10, fontSize: "text-2xl" },19 lg: { size: 200, strokeWidth: 12, fontSize: "text-4xl" },20}2122const colorSchemes = {23 cyan: { stroke: "stroke-cyan-500", glow: "from-cyan-500/40 to-blue-500/40" },24 purple: { stroke: "stroke-purple-500", glow: "from-purple-500/40 to-pink-500/40" },25 green: { stroke: "stroke-emerald-500", glow: "from-emerald-500/40 to-teal-500/40" },26 orange: { stroke: "stroke-orange-500", glow: "from-orange-500/40 to-amber-500/40" },27 gradient: { stroke: "", glow: "from-cyan-500/40 via-blue-500/40 to-purple-500/40" },28}2930const GlassGauge = React.forwardRef<HTMLDivElement, GlassGaugeProps>(31 (32 {33 className,34 value,35 max = 100,36 size = "md",37 showValue = true,38 label,39 colorScheme = "cyan",40 animated = true,41 ...props42 },43 ref,44 ) => {45 const [displayValue, setDisplayValue] = React.useState(0)46 const config = sizes[size]47 const colors = colorSchemes[colorScheme]48 const percentage = Math.min(Math.max((value / max) * 100, 0), 100)4950 const radius = (config.size - config.strokeWidth) / 251 const circumference = radius * 2 * Math.PI52 const strokeDashoffset = circumference - (percentage / 100) * circumference5354 React.useEffect(() => {55 if (!animated) {56 setDisplayValue(value)57 return58 }5960 const duration = 100061 const steps = 6062 const increment = value / steps63 let current = 064 let step = 06566 const timer = setInterval(() => {67 step++68 current = Math.min(current + increment, value)69 setDisplayValue(Math.round(current))7071 if (step >= steps) {72 clearInterval(timer)73 setDisplayValue(value)74 }75 }, duration / steps)7677 return () => clearInterval(timer)78 }, [value, animated])7980 const gradientId = React.useId()8182 return (83 <div ref={ref} className={cn("relative inline-flex flex-col items-center", className)} {...props}>84 {/* Glow effect */}85 <div86// … truncated
Files it writes
More from einui
All 44 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Base Widgetbase-widget | einui | Components | Free | 1 dep | |
| Calendar Widgetscalendar-widget | einui | Components | Free | 1 dep | |
| Clock Widgetsclock-widget | einui | Components | Free | 1 dep | |
| Glass Alert Dialogglass-alert-dialog | einui | Components | Free | 1 dep | |
| Glass Avatarglass-avatar | einui | Components | Free | 1 dep | |
| Glass Badgeglass-badge | einui | Components | Free | 1 dep | |
| Glass Breadcrumbglass-breadcrumb | einui | Components | Free | 1 dep | |
| Glass Buttonglass-button | einui | Components | Free | 2 deps |
