BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/diceui/base/gauge

gauge

diceui-base/gauge
FreeComponent

diceui/base publishes no description for this item.

Install it

npx shadcn@latest add https://raw.githubusercontent.com/sadmann7/diceui/HEAD/docs/public/r/styles/base-vega/gauge.json

Source

ui/gauge.tsxraw.githubusercontent.com/sadmann7/diceui/HEAD/docs/public/r/styles/base-vega/gauge.json · first 6 KB
1"use client";
2
3import { mergeProps } from "@base-ui/react/merge-props";
4import { useRender } from "@base-ui/react/use-render";
5import * as React from "react";
6import { cn } from "@/lib/utils";
7
8const GAUGE_NAME = "Gauge";
9const INDICATOR_NAME = "GaugeIndicator";
10const TRACK_NAME = "GaugeTrack";
11const RANGE_NAME = "GaugeRange";
12const VALUE_TEXT_NAME = "GaugeValueText";
13const LABEL_NAME = "GaugeLabel";
14
15const DEFAULT_MAX = 100;
16const DEFAULT_START_ANGLE = 0;
17const DEFAULT_END_ANGLE = 360;
18
19type GaugeState = "indeterminate" | "complete" | "loading";
20
21interface DivProps
22 extends React.ComponentProps<"div">,
23 useRender.ComponentProps<"div"> {}
24
25interface PathProps extends React.ComponentProps<"path"> {}
26
27function getGaugeState(
28 value: number | undefined | null,
29 maxValue: number,
30): GaugeState {
31 return value == null
32 ? "indeterminate"
33 : value === maxValue
34 ? "complete"
35 : "loading";
36}
37
38function getIsValidNumber(value: unknown): value is number {
39 return typeof value === "number" && Number.isFinite(value);
40}
41
42function getIsValidMaxNumber(max: unknown): max is number {
43 return getIsValidNumber(max) && max > 0;
44}
45
46function getIsValidValueNumber(
47 value: unknown,
48 min: number,
49 max: number,
50): value is number {
51 return getIsValidNumber(value) && value <= max && value >= min;
52}
53
54function getDefaultValueText(value: number, min: number, max: number): string {
55 const percentage = max === min ? 100 : ((value - min) / (max - min)) * 100;
56 return Math.round(percentage).toString();
57}
58
59function getInvalidValueError(
60 propValue: string,
61 componentName: string,
62): string {
63 return `Invalid prop \`value\` of value \`${propValue}\` supplied to \`${componentName}\`. The \`value\` prop must be a number between \`min\` and \`max\` (inclusive), or \`null\`/\`undefined\` for indeterminate state. The value will be clamped to the valid range.`;
64}
65
66function getInvalidMaxError(propValue: string, componentName: string): string {
67 return `Invalid prop \`max\` of value \`${propValue}\` supplied to \`${componentName}\`. Only numbers greater than 0 are valid. Defaulting to ${DEFAULT_MAX}.`;
68}
69
70function getNormalizedAngle(angle: number) {
71 return ((angle % 360) + 360) % 360;
72}
73
74function polarToCartesian(
75 centerX: number,
76 centerY: number,
77 radius: number,
78 angleInDegrees: number,
79) {
80 const angleInRadians = ((angleInDegrees - 90) * Math.PI) / 180.0;
81 return {
82 x: centerX + radius * Math.cos(angleInRadians),
83// … truncated

What it pulls in

npm packages

  • @base-ui/react

Files it writes

  • ui/gauge.tsx
  • lib/compose-refs.ts

Facts

Registry
diceui/base
Type
registry:ui
Access
Free
Files written
2
Licence
the repository states none
First indexed
2026-08-09
Last confirmed
yesterday

Go to the source

www.diceui.com sadmann7/diceui on GitHub Raw registry item This item as JSON

More from diceui/base

All 192 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
action-baraction-bardiceui/baseComponentsFree1 dep
angle-sliderangle-sliderdiceui/baseComponentsFree1 dep · 3 files
avatar-groupavatar-groupdiceui/baseComponentsFree1 dep
badge-overflowbadge-overflowdiceui/baseComponentsFree1 dep · 2 files
bannerbannerdiceui/baseComponentsFree1 dep
circular-progresscircular-progressdiceui/baseComponentsFree1 dep
client-onlyclient-onlydiceui/baseComponentsFreeno deps
color-pickercolor-pickerdiceui/baseComponentsFree1 dep · 2 files
BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex