Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/react-grid-layout

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/react-grid-layout

TypeScript definitions for react-grid-layout

  • 1.3.5
  • ts4.5
  • ts4.6
  • ts4.7
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • ts5.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
368K
decreased by-11.66%
Maintainers
1
Weekly downloads
 
Created

What is @types/react-grid-layout?

@types/react-grid-layout provides TypeScript definitions for the react-grid-layout library, which is a powerful and flexible grid layout system for React applications. It allows developers to create responsive, draggable, and resizable grid layouts with ease.

What are @types/react-grid-layout's main functionalities?

Creating a Basic Grid Layout

This code demonstrates how to create a basic grid layout using react-grid-layout. The layout array defines the position and size of each grid item.

import React from 'react';
import GridLayout from 'react-grid-layout';

const BasicGrid = () => {
  const layout = [
    { i: 'a', x: 0, y: 0, w: 1, h: 2 },
    { i: 'b', x: 1, y: 0, w: 3, h: 2 },
    { i: 'c', x: 4, y: 0, w: 1, h: 2 }
  ];
  return (
    <GridLayout className="layout" layout={layout} cols={12} rowHeight={30} width={1200}>
      <div key="a">A</div>
      <div key="b">B</div>
      <div key="c">C</div>
    </GridLayout>
  );
};

export default BasicGrid;

Draggable and Resizable Grid Items

This code shows how to make grid items draggable and resizable. The isDraggable and isResizable properties are set to true for each grid item.

import React from 'react';
import GridLayout from 'react-grid-layout';

const DraggableResizableGrid = () => {
  const layout = [
    { i: 'a', x: 0, y: 0, w: 1, h: 2, isDraggable: true, isResizable: true },
    { i: 'b', x: 1, y: 0, w: 3, h: 2, isDraggable: true, isResizable: true },
    { i: 'c', x: 4, y: 0, w: 1, h: 2, isDraggable: true, isResizable: true }
  ];
  return (
    <GridLayout className="layout" layout={layout} cols={12} rowHeight={30} width={1200}>
      <div key="a">A</div>
      <div key="b">B</div>
      <div key="c">C</div>
    </GridLayout>
  );
};

export default DraggableResizableGrid;

Responsive Grid Layout

This code demonstrates how to create a responsive grid layout that adapts to different screen sizes. The layouts object defines the layout for different breakpoints.

import React from 'react';
import { Responsive, WidthProvider } from 'react-grid-layout';

const ResponsiveGridLayout = WidthProvider(Responsive);

const ResponsiveGrid = () => {
  const layouts = {
    lg: [
      { i: 'a', x: 0, y: 0, w: 1, h: 2 },
      { i: 'b', x: 1, y: 0, w: 3, h: 2 },
      { i: 'c', x: 4, y: 0, w: 1, h: 2 }
    ],
    md: [
      { i: 'a', x: 0, y: 0, w: 1, h: 2 },
      { i: 'b', x: 1, y: 0, w: 2, h: 2 },
      { i: 'c', x: 3, y: 0, w: 1, h: 2 }
    ]
  };
  return (
    <ResponsiveGridLayout className="layout" layouts={layouts} breakpoints={{ lg: 1200, md: 996 }} cols={{ lg: 12, md: 10 }}>
      <div key="a">A</div>
      <div key="b">B</div>
      <div key="c">C</div>
    </ResponsiveGridLayout>
  );
};

export default ResponsiveGrid;

Other packages similar to @types/react-grid-layout

FAQs

Package last updated on 07 Nov 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc