circuit-board
componentry/circuit-boardFreeComponent
An interactive circuit board layout component with animated electricity paths that pulse between connected nodes. Fully theme-aware with automatic light/dark mode support.
Live preview
live · rendered by the registry
Rendered by componentry on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://componentry.dev/r/circuit-board.jsonSource
1"use client"23import * as React from "react"4import { motion } from "framer-motion"5import { cn } from "@workspace/ui/lib/utils"67interface CircuitNode {8 id: string9 x: number10 y: number11 label?: string12 icon?: React.ReactNode13 status?: "active" | "inactive" | "processing" | "error"14 size?: "sm" | "md" | "lg"15}1617interface CircuitConnection {18 from: string19 to: string20 animated?: boolean21 bidirectional?: boolean22 color?: string23 pulseColor?: string24}2526interface CircuitBoardProps extends React.HTMLAttributes<HTMLDivElement> {27 nodes: CircuitNode[]28 connections: CircuitConnection[]29 width?: number30 height?: number31 gridSize?: number32 showGrid?: boolean33 gridColor?: string34 traceColor?: string35 pulseColor?: string36 nodeColor?: string37 pulseSpeed?: number38 traceWidth?: number39 /** Force a specific theme variant. Defaults to auto-detect from system. */40 variant?: "light" | "dark" | "auto"41}4243function CircuitBoard({44 nodes,45 connections,46 width = 600,47 height = 400,48 gridSize = 20,49 showGrid = true,50 gridColor,51 traceColor,52 pulseColor,53 nodeColor,54 pulseSpeed = 2,55 traceWidth = 2,56 variant = "auto",57 className,58 ...props59}: CircuitBoardProps) {60 // Theme-aware color defaults61 const [isDark, setIsDark] = React.useState(true)6263 React.useEffect(() => {64 if (variant !== "auto") {65 setIsDark(variant === "dark")66 return67 }6869 // Check for dark class on html/body70 const checkTheme = () => {71 const isDarkMode = document.documentElement.classList.contains("dark") ||72 document.body.classList.contains("dark")73 setIsDark(isDarkMode)74 }7576 checkTheme()7778 // Listen for changes79 const observer = new MutationObserver(checkTheme)80 observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class"] })81 observer.observe(document.body, { attributes: true, attributeFilter: ["class"] })8283 const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)")84 mediaQuery.addEventListener("change", checkTheme)8586 return () => {87 observer.disconnect()88 mediaQuery.removeEventListener("change", checkTheme)89 }90 }, [variant])9192 // Compute theme-aware colors93 const computedGridColor = gridColor || (isDark ? "rgba(163, 163, 163, 0.08)" : "rgba(64, 64, 64, 0.12)")94 const computedTraceColor = traceColor || (isDark ? "rgba(163, 163, 163, 0.25)" : "rgba(64, 64, 64, 0.35)")95// … truncated
More from componentry
All 59 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Gradientanimated-gradient | componentry | Components | Free | no deps | |
| ASCII Effectascii-effect | componentry | Components | Free | no deps | |
| Aurora Flowaurora-flow | componentry | Components | Free | no deps | |
| auth-modalauth-modal | componentry | Components | Free | no deps | |
| border-beamborder-beam | componentry | Components | Free | no deps | |
| closing-plasmaclosing-plasma | componentry | Components | Free | no deps | |
| collection-surfercollection-surfer | componentry | Components | Free | no deps | |
| Command Menucommand-menu | componentry | Components | Free | no deps |
