{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"signal-strength","type":"registry:ui","title":"Signal strength","description":"Four bars for the quality of a connection. The bars rise and fall one after another as the level changes and take a colour for how good it is; while searching a light sweeps across them, and offline they grey out under a slash.","dependencies":["clsx","tailwind-merge"],"registryDependencies":["https://caliperui.site/r/styles.json"],"files":[{"path":"ui/lib/cn.ts","type":"registry:ui","target":"components/ui/lib/cn.ts","content":"import { clsx, type ClassValue } from \"clsx\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\nconst twMerge = extendTailwindMerge({\n  extend: { theme: { radius: [\"control\", \"surface\", \"overlay\"], shadow: [\"overlay\"] } },\n});\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n"},{"path":"ui/signal-strength.tsx","type":"registry:ui","target":"components/ui/signal-strength.tsx","content":"\"use client\";\nimport type { ComponentProps, CSSProperties } from \"react\";\nimport { cn } from \"./lib/cn\";\nimport \"./signal-strength.css\";\n\nexport type SignalStrengthProps = Omit<ComponentProps<\"span\">, \"children\"> & {\n  /** Bars lit, from 0 to 4. */\n  level: number;\n  /** Searching sweeps the bars; offline greys them out with a slash. */\n  status?: \"connected\" | \"searching\" | \"offline\";\n  /** What the signal is of, e.g. \"Network\". Pass \"\" when the row says it already. */\n  label?: string;\n  size?: \"sm\" | \"md\";\n};\n\nconst quality = [\"No signal\", \"Poor\", \"Fair\", \"Good\", \"Excellent\"];\n\n/**\n * Four bars for the quality of a connection: a call, a sync, a device's network. The bars rise and fall one after\n * another as the level changes and take a colour for how good it is (red poor, amber fair, green good); while\n * searching a light sweeps across them, and offline they grey out under a slash. Under reduced motion the bars\n * change without rising and the sweep is replaced by a dim pulse.\n */\nexport function SignalStrength({ level, status = \"connected\", label = \"Signal\", size = \"md\", className, style, ...props }: SignalStrengthProps) {\n  const lit = status === \"connected\" ? Math.max(0, Math.min(4, Math.round(level))) : 0;\n  const name = status === \"connected\" ? `${quality[lit]}, ${lit} of 4 bars` : status === \"searching\" ? \"Searching\" : \"Offline\";\n  return (\n    <span\n      role={label ? \"img\" : undefined}\n      aria-label={label ? `${label}: ${name}` : undefined}\n      aria-hidden={label ? undefined : true}\n      data-slot=\"signal-strength\"\n      data-status={status}\n      data-level={lit}\n      data-size={size}\n      className={cn(\"inline-flex\", className)}\n      style={style}\n      {...props}\n    >\n      {[1, 2, 3, 4].map((bar) => (\n        <i key={bar} data-on={bar <= lit ? \"\" : undefined} style={{ \"--ss-i\": bar } as CSSProperties} />\n      ))}\n      {status === \"offline\" && <b data-slot=\"ss-slash\" />}\n    </span>\n  );\n}\n"},{"path":"ui/signal-strength.css","type":"registry:file","target":"components/ui/signal-strength.css","content":"/* signal-strength.tsx's styles; it imports this file. Edit freely. */\n@layer theme, base, components, utilities;\n\n@layer components {\n  /* Signal strength: bars rise in turn; colour follows quality; a sweep while searching. */\n  [data-slot=\"signal-strength\"] { --ss-w: 4px; --ss-h: 16px; position: relative; align-items: flex-end; gap: 2px; height: var(--ss-h); color: var(--muted-foreground); }\n  [data-slot=\"signal-strength\"][data-size=\"sm\"] { --ss-w: 3px; --ss-h: 12px; }\n  [data-slot=\"signal-strength\"][data-level=\"1\"] { color: var(--destructive); }\n  [data-slot=\"signal-strength\"][data-level=\"2\"] { color: var(--warning); }\n  [data-slot=\"signal-strength\"]:is([data-level=\"3\"], [data-level=\"4\"]) { color: var(--success); }\n  [data-slot=\"signal-strength\"] i { width: var(--ss-w); height: calc(var(--ss-h) * (0.25 + var(--ss-i) * 0.1875)); border-radius: 1px; background: color-mix(in oklab, var(--foreground) 16%, transparent); transform-origin: bottom; transition: background-color var(--duration-normal) var(--ease-out) calc(var(--ss-i) * 40ms), scale var(--duration-normal) var(--ease-settle) calc(var(--ss-i) * 40ms); }\n  [data-slot=\"signal-strength\"] i[data-on] { background: currentColor; }\n  [data-slot=\"signal-strength\"][data-status=\"searching\"] i { animation: ss-sweep 1.2s var(--ease-in-out) calc(var(--ss-i) * 120ms) infinite; }\n  [data-slot=\"signal-strength\"] [data-slot=\"ss-slash\"] { position: absolute; left: -2px; right: -2px; top: 50%; height: 1.5px; background: var(--muted-foreground); rotate: -40deg; box-shadow: 0 0 0 1px var(--background); }\n  @media (prefers-reduced-motion: reduce) {\n    [data-slot=\"signal-strength\"] i { transition: none; }\n    [data-slot=\"signal-strength\"][data-status=\"searching\"] i { animation: ss-pulse 2s ease-in-out infinite; }\n  }\n  @keyframes ss-sweep { 0%, 100% { background-color: color-mix(in oklab, var(--foreground) 16%, transparent); } 30% { background-color: var(--muted-foreground); } }\n  @media (prefers-reduced-motion: reduce) {\n    @keyframes ss-pulse { 50% { opacity: 0.5; } }\n  }\n}\n"}],"categories":["motion"],"meta":{"tier":"free","license":"MIT","family":"changing-values","docs":"/docs/components/signal-strength"}}