eo-n/ui
UIComponentsMeterNew

Meter

Visualizes progress, a measurement, or value within a known range.

Battery Level

Installation

CLI

npx shadcn@latest add "https://eo-n.vercel.app/r/meter"

Manual

Copy and paste the following code into your project.

"use client";
 
import * as React from "react";
import { Meter as MeterPrimitive } from "@base-ui-components/react/meter";
 
import { cn } from "@/lib/utils";
 
function Meter({
  className,
  children,
  ...props
}: React.ComponentProps<typeof MeterPrimitive.Root>) {
  return (
    <MeterPrimitive.Root
      data-slot="meter"
      className={cn(
        "relative grid w-full grid-cols-1 gap-1 overflow-hidden select-none has-[[data-slot=meter-label]]:grid-cols-2",
        className
      )}
      {...props}
    >
      {children}
      <MeterPrimitive.Track
        data-slot="meter-track"
        className="bg-secondary col-span-full block h-2 w-full overflow-hidden rounded-full"
      >
        <MeterPrimitive.Indicator
          data-slot="meter-indicator"
          className="bg-primary block transition-all duration-500"
        />
      </MeterPrimitive.Track>
    </MeterPrimitive.Root>
  );
}
 
function MeterValue({
  className,
  ...props
}: React.ComponentProps<typeof MeterPrimitive.Value>) {
  return (
    <MeterPrimitive.Value
      data-slot="meter-value"
      className={cn(
        "text-foreground text-right text-sm font-medium",
        className
      )}
      {...props}
    />
  );
}
 
function MeterLabel({
  className,
  ...props
}: React.ComponentProps<typeof MeterPrimitive.Label>) {
  return (
    <MeterPrimitive.Label
      data-slot="meter-label"
      className={cn("text-foreground text-sm font-medium", className)}
      {...props}
    />
  );
}
 
export { Meter, MeterValue, MeterLabel };
Update the import paths to match your project setup.

Usage

Import all parts and piece them together.

import { Meter, MeterLabel, MeterValue } from "@/components/ui/meter";
<Meter value={34}>
  <MeterLabel>Battery Level</MeterLabel>
  <MeterValue />
</Meter>

On this page