npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@quyenlbv/circuitlab-react

v0.1.11

Published

Responsive React SVG viewport adapter for CircuitLab Edu

Readme

@quyenlbv/circuitlab-react

Responsive React SVG viewport adapter for CircuitLab Edu. The simulation engine remains framework-independent in @quyenlbv/circuitlab-core; this package provides a responsive SVG host for React applications.

Install

npm install @quyenlbv/circuitlab-core @quyenlbv/circuitlab-react react

React is a peer dependency. This package does not bundle React. TypeScript consumers should also have @types/react installed.

Quick start

import { CircuitCanvas } from "@quyenlbv/circuitlab-react";

export function ExampleCircuit() {
  return (
    <section style={{ width: "100%", minWidth: 0 }}>
      <CircuitCanvas
        width="auto"
        height="auto"
        minHeight={280}
        aspectRatio={16 / 9}
        maintainAspectRatio
        ariaLabel="Example circuit"
      >
        {({ width, height }) => (
          <g>
            <path d={`M 40 40 H ${Math.max(40, width - 40)} V ${Math.max(40, height - 40)}`} fill="none" stroke="currentColor" strokeWidth="2" />
          </g>
        )}
      </CircuitCanvas>
    </section>
  );
}

Sizing options

Options can be grouped into a chart-library-style options object. Explicit component props override matching option values.

<CircuitCanvas
  options={{
    width: "auto",
    height: "auto",
    responsive: true,
    aspectRatio: 16 / 9,
    maintainAspectRatio: true,
    minHeight: 240,
    maxWidth: 1200,
  }}
>
  {({ width, height }) => <CircuitDrawing width={width} height={height} />}
</CircuitCanvas>

| Option | Default | Meaning | | --- | --- | --- | | width | "auto" | "auto" fills the parent content width; a number fixes CSS width in pixels. | | height | "auto" | "auto" uses parent/ratio sizing or the minimum height; a number fixes height in pixels. | | minWidth / minHeight | 0 / context-dependent | Lower size bounds in pixels. Auto-height defaults to 320 unless an aspect ratio is maintained; fixed-height canvases default to 0. | | maxWidth / maxHeight | unlimited | Optional upper size bounds in pixels. | | aspectRatio | unset | Width divided by height, e.g. 16 / 9. | | maintainAspectRatio | false | With auto height and a ratio, derive height from the measured width. | | responsive | true | Enables responsive sizing behavior. | | padding | 0 | Inner wrapper padding in pixels. | | devicePixelRatio | "auto" | Reserved sizing metadata for renderers that need a backing-store pixel ratio; SVG itself remains resolution-independent. | | onResize | unset | Receives measured { width, height } after container resize. |

The component uses ResizeObserver to respond to parent/container changes, including grid changes, sidebars, and tab layouts. It falls back to window resize events where ResizeObserver is unavailable. Use minWidth: 0 on flex/grid ancestors to prevent intrinsic content width from forcing horizontal overflow.

The child render function receives the current logical width, height, pixelRatio, and responsive values. SVG coordinates should be drawn against these logical dimensions. Do not multiply SVG coordinates by device pixel ratio.

Integration guidance

  • Let the embedding page own the parent layout; this package does not impose viewport-wide positioning.
  • For a panel that should fill available height, set the parent and canvas style={{ height: "100%" }} and ensure ancestors have a defined height.
  • For a proportional diagram, use aspectRatio and maintainAspectRatio.
  • For an editor that needs vertical room to grow, leave maintainAspectRatio={false} and set a suitable minHeight.
  • The SVG host is a rendering surface, not a circuit editor by itself. Wire gestures, selection, pan/zoom, and electrical calculations remain application features.
  • In SSR environments, browser measurement starts after mount; do not assume a meaningful container size during server rendering.

Core sizing helper

Non-React integrations can use normalizeViewportConfig and resolveViewportSize from @quyenlbv/circuitlab-core to normalize options and resolve measured dimensions without importing React or touching the DOM.