Skip to content
synccn

Gauge

Half-circle meter that changes colour at thresholds.

42%CPU usage

Turns amber at 60% and red at 85%.

Playground

Change the props and copy the code. The controls come from the component's TypeScript types.

72CPU

Props

size220
import { Gauge } from "@/components/ui/charts";<Gauge value={72} label="CPU" />

Installation

$ pnpm dlx shadcn@latest add @synccn/gauge

First time in this project? Connect synccn with one command.

Usage

import { Gauge } from "@/components/ui/charts";<Gauge value={42} label="CPU usage" />

API reference

Generated from the component's TypeScript types, so it always matches the code.

Gauge

Half-circle gauge with optional threshold colours.

  • valuerequired
    number

    Current value.

  • max
    number

    Default 100

    Value that fills the gauge.

  • label
    string

    Caption under the value.

  • size
    number

    Default 220

    Width in pixels.

  • thresholds
    [number, number]

    Default [60, 85]

    Percentages where the colour turns amber, then red.

  • format
    (value: number) => React.ReactNode

    Default (v) => Math.round(v)

    Formats the centre value.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

npm packages

Accessibility

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: img, meter
  • ARIA attributes: aria-label, aria-pressed, aria-valuemax, aria-valuemin, aria-valuenow