usage-meter-03
dashboardblocks/usage-meter-03FreeComponent
dashboardblocks publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by dashboardblocks on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://dashboardblocks.com/r/usage-meter-03.jsonSource
1'use client'23import { AnimatedNumber } from '@/registry/components/dashboardblocks/animated-number'4import { ProgressBar } from '@/registry/components/dashboardblocks/progress-bar'56import { Card, CardContent, CardDescription, CardTitle } from '@/components/ui/card'78interface ResourceUsage {9 limit: number10 name: string11 unit: string12 used: number13}1415interface UsageMeter3Props {16 resources: ResourceUsage[]17 title: string18}1920const exampleProps: UsageMeter3Props = {21 resources: [22 { name: 'CPU', used: 45, limit: 100, unit: '%' },23 { name: 'Memory', used: 6.2, limit: 8, unit: 'GB' },24 { name: 'Bandwidth', used: 847, limit: 1000, unit: 'GB' },25 ],26 title: 'Resource Usage',27}2829const UsageMeter3 = (props: UsageMeter3Props) => {30 const { resources, title } = props31 return (32 <Card>33 <CardContent className='space-y-4'>34 <CardTitle className='text-base font-medium'>{title}</CardTitle>35 <div className='space-y-4'>36 {resources.map((resource) => {37 const percentage = (resource.used / resource.limit) * 10038 const safePercentage = Number.isFinite(percentage) ? percentage : 039 const normalized = Math.min(100, Math.max(0, safePercentage))40 const fillClassName =41 normalized >= 9542 ? 'bg-destructive'43 : normalized >= 8044 ? 'bg-amber-500'45 : undefined46 return (47 <div key={resource.name} className='space-y-1'>48 <div className='flex items-end justify-between text-sm'>49 <span className='font-medium'>{resource.name}</span>50 <span className='text-xs text-muted-foreground'>51 <AnimatedNumber52 value={resource.used}53 formatter={(value) => value.toLocaleString()}54 />{' '}55 / {resource.limit.toLocaleString()}56 {resource.unit}57 </span>58 </div>59 <ProgressBar percentage={percentage} fillClassName={fillClassName} />60 </div>61 )62 })}63 </div>64 <CardDescription className='text-xs'>Updated just now</CardDescription>65 </CardContent>66 </Card>67 )68}6970export {71 UsageMeter3,72 exampleProps as usageMeter3ExampleProps,73 type UsageMeter3Props,74 type ResourceUsage,75}
What it pulls in
Other registry items
Files it writes
More from dashboardblocks
All 36 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Activity Feedactivity-feed | dashboardblocks | Components | Free | 1 dep | |
| activity-feed-01activity-feed-01 | dashboardblocks | Components | Free | 1 dep | |
| activity-feed-02activity-feed-02 | dashboardblocks | Components | Free | 1 dep | |
| activity-feed-03activity-feed-03 | dashboardblocks | Components | Free | 1 dep | |
| activity-feed-04activity-feed-04 | dashboardblocks | Components | Free | 1 dep | |
| activity-feed-05activity-feed-05 | dashboardblocks | Components | Free | 1 dep | |
| Animated Numberanimated-number | dashboardblocks | Components | Free | no deps | |
| Animated Waveanimated-wave | dashboardblocks | Components | Free | no deps |
