MCPcopy Create free account
hub / github.com/adobe/react-spectrum / Meter

Function Meter

starters/tailwind/src/Meter.tsx:12–45  ·  view source on GitHub ↗
({label, ...props}: MeterProps)

Source from the content-addressed store, hash-verified

10}
11
12export function Meter({label, ...props}: MeterProps) {
13 return (
14 <AriaMeter
15 {...props}
16 className={composeTailwindRenderProps(
17 props.className,
18 'flex flex-col gap-2 font-sans max-w-full'
19 )}>
20 {({percentage, valueText}) => (
21 <>
22 <div className="flex justify-between gap-2">
23 <Label>{label}</Label>
24 <span
25 className={`text-sm ${percentage >= 80 ? 'text-red-600 dark:text-red-500' : 'text-neutral-600 dark:text-neutral-400'}`}>
26 {percentage >= 80 && (
27 <AlertTriangle
28 aria-label="Alert"
29 className="inline-block w-4 h-4 align-text-bottom"
30 />
31 )}
32 {' ' + valueText}
33 </span>
34 </div>
35 <div className="w-64 max-w-full h-2 rounded-full bg-neutral-300 dark:bg-neutral-700 outline outline-1 -outline-offset-1 outline-transparent relative">
36 <div
37 className={`absolute top-0 left-0 h-full rounded-full ${getColor(percentage)} forced-colors:bg-[Highlight]`}
38 style={{width: percentage + '%'}}
39 />
40 </div>
41 </>
42 )}
43 </AriaMeter>
44 );
45}
46
47function getColor(percentage: number) {
48 if (percentage < 70) {

Callers

nothing calls this directly

Calls 2

getColorFunction · 0.85

Tested by

no test coverage detected