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

dxf-react

v0.1.0

Published

React DXF file viewer — render AutoCAD DXF drawings in the browser with Three.js. Built-in parser, vector text rendering, TypeScript support.

Downloads

173

Readme

dxf-react

CI npm license TypeScript

React DXF viewer component — render AutoCAD DXF drawings in the browser. A thin, fully typed wrapper around dxf-render, the framework-agnostic Three.js/WebGL engine that also powers dxf-vuer.

Live Demo | GitHub | Open in StackBlitz

Why dxf-react?

  • One tag — drop in <DXFViewer> with typed props, refs, and callbacks
  • Runs in the browser — DXF is parsed client-side in a Web Worker; no backend, no AutoCAD, nothing uploaded
  • 22 entity types — lines, arcs, splines, hatches, dimensions, leaders, multilines, regions, and block inserts with attributes
  • Crisp vector text — triangulated opentype.js glyphs stay sharp at any zoom
  • Interactive — pan, zoom, layer toggles, measure tools, dark theme, and PNG export
  • TypeScript-native — fully typed props with onEntityHover / onEntityClick callbacks over the dxf-render engine

Installation

npm install dxf-react dxf-render three

Peer dependencies: react >= 18, react-dom >= 18, three >= 0.160, dxf-render >= 1.7.0.

Quick Start

import { useRef } from "react";
import { DXFViewer, type DXFViewerHandle } from "dxf-react";
import "dxf-react/style.css";

export function App() {
  const viewer = useRef<DXFViewerHandle>(null);

  async function loadFile(e: React.ChangeEvent<HTMLInputElement>) {
    const file = e.target.files?.[0];
    if (!file) return;
    viewer.current?.loadDXFFromText(await file.text());
  }

  return (
    <div style={{ display: "flex", flexDirection: "column", height: "100vh" }}>
      <input type="file" accept=".dxf" onChange={loadFile} />
      <div style={{ flex: 1, display: "flex" }}>
        <DXFViewer ref={viewer} fileName="drawing.dxf" showResetButton />
      </div>
    </div>
  );
}

You can also pass a parsed dxfData object or a url prop instead of using the ref:

import { DXFViewer, parseDxf } from "dxf-react";

const dxfData = parseDxf(text);
// ...
<DXFViewer dxfData={dxfData} />
<DXFViewer url="/drawings/floor-plan.dxf" />

dxf-react is a client-only component (WebGL/canvas). In SSR frameworks like Next.js App Router, render it in a client component ("use client").

Components

| Component | Description | | --------------------- | ------------------------------------------------------------------------------------ | | DXFViewer | Main viewer: Three.js scene, layer panel, toolbar, rulers, measurement, drag-and-drop, dark theme, render-props | | ViewerToolbar | Toolbar with export, fit-to-view, fullscreen + measurement buttons. Accepts an extra slot | | FileUploader | .dxf file input button. Fires onFileSelected(file) | | LayerPanel | Collapsible layer-visibility panel with color swatches + prefix grouping | | PropertiesPanel | Read-only property inspector for the clicked entity | | UnsupportedEntities | Collapsible list of unsupported entity types | | DXFStatistics | File statistics (entities, layers, blocks, AutoCAD version) |

DXFViewer props (selected)

The full, typed prop list lives in the bundled .d.ts (DXFViewerProps). Highlights:

  • Data: dxfData, url, fileName, fontUrl
  • Visibility toggles: showResetButton, showFullscreenButton, showExportButton, showFileName, showCoordinates, showZoomLevel, showDebugInfo, showRulers, showLayerPanel, showPropertiesPanel, showMeasureButton / …AreaButton / …AngleButton
  • Behavior: autoFit, allowDrop, darkTheme, keyboardNavigation, antialiasing
  • Interaction: pickingEnabled, highlightOnHover, highlightAssociated, highlightColor, rectangleSelection, rectangleSelectionModifier, rectangleSelectionMode
  • Measurement (controlled): measureMode + onMeasureModeChange, measureUnits, measureAreaUnits, measureAngleUnits, measureColor, snapToGeometry
  • Layers: groupLayers, persistLayersKey, hiddenLayers (controlled) + onHiddenLayersChange
  • Rulers: rulerUnits
  • Styling: classes (a ViewerClasses map of .dxfk-* hook classes), *Position overlay placement

Events (callback props)

onDxfLoaded, onDxfData, onError, onUnsupportedEntities, onResetView, onFileDropped, onEntityHover, onEntityClick, onEntitiesSelect, onSelectionStart, onSelectionEnd, onLayerHover, onHiddenLayersChange, onMeasureModeChange, onMeasure, onMeasureArea, onMeasureAngle, onMeasureCancel.

Render-props (custom UI)

renderToolbar(ctx), toolbarExtra, renderOverlay(ctx), renderLoading(ctx), renderError(ctx), renderEmptyState() — the React analogues of dxf-vuer's scoped slots.

Imperative API (ref)

const viewer = useRef<DXFViewerHandle>(null);
// loadDXFFromText / Data / Url / Buffer / Blob, resetView, resize, exportToPNG,
// getRenderer, highlight, clearHighlight, clearSelection, zoomToEntity, zoomToLayer,
// getAssociations, findAssociationsByHandle, getPickingIndex, clearMeasure, setMeasureMode

Hooks

Every interaction is also exposed as a standalone hook for building a custom UI: useDXFRenderer, useThreeScene, useLayers, usePicking, useHighlight, useSnap, useRectangleSelection, useMeasurement, useAreaMeasurement, useAngleMeasurement. All of dxf-render is re-exported from dxf-react for convenience.

Customizing styles

All public elements carry stable, low-specificity .dxfk-* hook classes, and the theme is driven by --dxfk-* CSS custom properties (override them on :root or a wrapper). The classes prop merges extra class names onto each part (Headless-UI style). This surface is shared with dxf-vuer.

License

MIT © Timur Arbaev