Skip to content

MetricProgressBar

Purpose

MetricProgressBar displays progress or percentage metrics with:

  • Configurable value position
  • Custom formatting
  • Size variants
  • Customizable colors

When to use

Use MetricProgressBar for:

  • Goal progress indicators
  • Capacity/usage meters
  • Completion percentages
  • Budget utilization

Basic usage

tsx
import { MetricProgressBar } from '@/shared/ui/components/MetricProgressBar'

<MetricProgressBar value={75} />

With label

tsx
<MetricProgressBar
  value={75}
  label="Storage used"
  valuePosition="inline-right"
/>

Custom formatting

tsx
<MetricProgressBar
  value={750}
  max={1000}
  formatValue={(percent) => `${750} / 1000 MB`}
  valuePosition="top-right"
/>

Props

PropTypeDefaultDescription
valuenumberRequiredCurrent value
maxnumber100Maximum value
labelReactNode-Label text
showValuebooleantrueShow percentage
valuePositionValuePosition'top-right'Value placement
formatValue(percent: number) => ReactNode-Custom formatter
size'sm' | 'md''sm'Bar height
trackClassNamestring-Track (background) class
indicatorClassNamestring-Filled bar class
classNamestring-Container class
labelClassNamestring-Label text class
valueClassNamestring-Value text class

Value positions

PositionDescription
top-rightValue above bar, right-aligned
top-centerValue above bar, centered
inline-rightLabel left, value right, above bar
noneNo value displayed

Custom colors

tsx
// Success color
<MetricProgressBar
  value={100}
  indicatorClassName="bg-green-500"
/>

// Warning color
<MetricProgressBar
  value={85}
  indicatorClassName="bg-amber-500"
/>

// Danger color
<MetricProgressBar
  value={95}
  indicatorClassName="bg-red-500"
/>

Notes

  • Value is automatically clamped between 0-100%
  • Use max prop when value isn't already a percentage
  • Default indicator color is bg-primary
  • Track uses bg-muted by default