
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
fabric-layers-react
Advanced tools
A fabric.js coordinate-plane (grid) & layers library for React applications.
Important: This library now depends on the
fabric-layerscore library. Please see the Migration Guide for details on updating from previous versions.
# First ensure you're using the correct Node version
nvm use
# Install the packages
npm install fabric-layers fabric-layers-react fabric-pure-browser react
# First ensure you're using the correct Node version
nvm use
# Install the packages
yarn add fabric-layers fabric-layers-react fabric-pure-browser react
The library is now split into two packages:
fabric-layers - Core functionality without React dependencies
fabric-layers-react - React extensions
For most users, you can continue to import React components from fabric-layers-react as before. For advanced users who need direct access to core functionality, you can now import from either library depending on your needs.
// Import React components from fabric-layers-react
import { CanvasLayer, useGridContext } from 'fabric-layers-react';
// Import core functionality directly from fabric-layers
import { GridManager, Point, Constants } from 'fabric-layers';
This separation allows for:
import React, { useEffect, useRef } from 'react';
import { CoordinatePlane } from 'fabric-layers-react';
function MyCanvas() {
const containerRef = useRef(null);
const planeRef = useRef(null);
useEffect(() => {
if (containerRef.current && !planeRef.current) {
// Create coordinate plane
planeRef.current = new CoordinatePlane(containerRef.current, {
gridEnabled: true,
zoomEnabled: true,
selectEnabled: true
});
}
return () => {
// Clean up
if (planeRef.current) {
// Handle cleanup if needed
}
};
}, []);
return (
<div ref={containerRef} style={{ width: '100%', height: '500px' }} />
);
}
import React, { useEffect, useRef } from 'react';
import { CoordinatePlane, ImageLayer, Polyline } from 'fabric-layers-react';
function MyLayeredCanvas() {
const containerRef = useRef(null);
const planeRef = useRef(null);
useEffect(() => {
if (containerRef.current && !planeRef.current) {
// Create coordinate plane
const plane = new CoordinatePlane(containerRef.current, {
gridEnabled: true
});
planeRef.current = plane;
// Add an image layer
const image = new ImageLayer({
url: 'path/to/image.png',
position: { x: 0, y: 0 },
width: 500,
height: 300
});
// Add a shape layer
const path = new Polyline({
points: [
{ x: 10, y: 10 },
{ x: 100, y: 50 },
{ x: 200, y: 10 }
],
strokeColor: '#ff0000',
strokeWidth: 2
});
// Add layers to the coordinate plane
plane.addLayer(image);
plane.addLayer(path);
}
}, []);
return (
<div ref={containerRef} style={{ width: '100%', height: '500px' }} />
);
}
import React, { useEffect, useRef } from 'react';
import { CoordinatePlane, GridManager } from 'fabric-layers-react';
function CustomGrid() {
const containerRef = useRef(null);
useEffect(() => {
if (containerRef.current) {
// Create coordinate plane
const plane = new CoordinatePlane(containerRef.current);
// Create a grid manager
const gridManager = new GridManager({
coordinatePlane: plane,
spacing: 20,
color: '#0099cc',
opacity: 0.4,
showLabels: true
});
// Customize the grid
gridManager.setColor('#333333');
gridManager.setSpacing(50);
gridManager.setOpacity(0.6);
}
}, []);
return (
<div ref={containerRef} style={{ width: '100%', height: '500px' }} />
);
}
For more advanced usage examples and detailed API documentation, please refer to the API Documentation.
import React, { useEffect, useRef } from 'react';
import { CoordinatePlane, LayerManager, ImageLayer, Marker } from 'fabric-layers-react';
function AdvancedLayerManagement() {
const containerRef = useRef(null);
useEffect(() => {
if (containerRef.current) {
// Create coordinate plane
const plane = new CoordinatePlane(containerRef.current);
// Create a layer manager
const layerManager = new LayerManager({
coordinatePlane: plane
});
// Create layers
const baseMap = new ImageLayer({
id: 'base-map',
url: 'path/to/map.png',
position: { x: 0, y: 0 }
});
const marker1 = new Marker({
id: 'marker-1',
position: { x: 100, y: 100 },
label: 'Location A'
});
const marker2 = new Marker({
id: 'marker-2',
position: { x: 200, y: 150 },
label: 'Location B'
});
// Add layers to the manager
layerManager.addLayer(baseMap);
layerManager.addLayer(marker1);
layerManager.addLayer(marker2);
// Sort layers by z-index
layerManager.sortLayers();
// You can now easily manage layers
// For example, to get a layer by id:
const locationA = layerManager.getLayer('marker-1');
// To hide all layers except the base map:
layerManager.hideAllLayers();
layerManager.getLayer('base-map').setVisible(true);
}
}, []);
return (
<div ref={containerRef} style={{ width: '100%', height: '500px' }} />
);
}
fabric-layers-react works in all modern browsers that support Canvas, including:
# Clone the repository
git clone https://github.com/ajoslin103/fabric-layers-react.git
cd fabric-layers-react
# Install dependencies
npm install
# Build the library
npm run build
# Run development server
npm start
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
A fabric.js coordinate-plane (grid) & layers library for React
The npm package fabric-layers-react receives a total of 1 weekly downloads. As such, fabric-layers-react popularity was classified as not popular.
We found that fabric-layers-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.