{"id":31370754,"url":"https://github.com/morris/fast-grid-layout","last_synced_at":"2026-06-19T08:32:30.995Z","repository":{"id":312708002,"uuid":"1039539191","full_name":"morris/fast-grid-layout","owner":"morris","description":"Fast editable grid layout system","archived":false,"fork":false,"pushed_at":"2026-04-07T16:19:38.000Z","size":2178,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-07T17:31:20.714Z","etag":null,"topics":["grid","layout","react","vanilla"],"latest_commit_sha":null,"homepage":"https://morris.github.io/fast-grid-layout/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/morris.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-17T13:09:25.000Z","updated_at":"2026-04-07T16:19:42.000Z","dependencies_parsed_at":"2025-09-01T14:51:40.534Z","dependency_job_id":"267a5cf2-48c0-470b-b561-f1042639ea21","html_url":"https://github.com/morris/fast-grid-layout","commit_stats":null,"previous_names":["morris/fast-grid-layout"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/morris/fast-grid-layout","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morris%2Ffast-grid-layout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morris%2Ffast-grid-layout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morris%2Ffast-grid-layout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morris%2Ffast-grid-layout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/morris","download_url":"https://codeload.github.com/morris/fast-grid-layout/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morris%2Ffast-grid-layout/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34523982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-19T02:00:06.005Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["grid","layout","react","vanilla"],"created_at":"2025-09-27T19:02:46.082Z","updated_at":"2026-06-19T08:32:30.990Z","avatar_url":"https://github.com/morris.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fast Grid Layout\n\nFast editable grid layout system similar to\n[React Grid Layout](https://github.com/react-grid-layout/react-grid-layout).\nPerformant even at **hundreds of items**. Vanilla/framework-agnostic.\n\nThe **\"rising tide\" layout compaction algorithm** developed here eventually\n[made its way back into React Grid Layout](https://github.com/react-grid-layout/react-grid-layout/pull/2184).\nThanks for picking it up!\n\n\u003cimg src=\"./docs/assets/demo.webp\" width=\"640\"\u003e\n\n- Multi-item drag and drop\n- Robust, deterministic manipulation (less accidents)\n- Touch support (tap to select, then manipulate)\n- Responsive breakpoints with auto-generation\n- Data format compatible with\n  [React Grid Layout](https://github.com/react-grid-layout/react-grid-layout).\n- 4 KB (minimized \u0026 gzipped)\n\nTry the **[Demo (Vanilla)](https://morris.github.io/fast-grid-layout/) |\n[Demo (with Breakpoints)](https://morris.github.io/fast-grid-layout/responsive.html)\n| [Demo (React)](https://morris.github.io/fast-grid-layout/react.html)**\n\n## Installation\n\nWith npm:\n\n```sh\nnpm install fast-grid-layout\n```\n\nVia CDN:\n\n```html\n\u003clink\n  href=\"https://cdn.jsdelivr.net/npm/fast-grid-layout@0.1/dist/fast-grid-layout.min.css\"\n  rel=\"stylesheet\"\n/\u003e\n\u003cscript type=\"module\"\u003e\n  import { GridLayout } from 'https://cdn.jsdelivr.net/npm/fast-grid-layout@0.1/dist/fast-grid-layout.min.js';\n\u003c/script\u003e\n```\n\n## Usage\n\nInclude, copy, and/or customize the [CSS](./docs/css/fast-grid-layout.css) |\n[SCSS](./src/fast-grid-layout.scss).\n\n### Vanilla\n\n```html\n\u003clink\n  href=\"https://cdn.jsdelivr.net/npm/fast-grid-layout@0.1/dist/fast-grid-layout.min.css\"\n  rel=\"stylesheet\"\n/\u003e\n\n\u003cdiv id=\"layout\"\u003e\n  \u003cdiv data-key=\"a\"\u003eA\u003c/div\u003e\n  \u003cdiv data-key=\"b\"\u003eB\u003c/div\u003e\n  \u003cdiv data-key=\"c\"\u003eC\u003c/div\u003e\n\u003c/div\u003e\n\n\u003cscript type=\"module\"\u003e\n  import { GridLayout } from 'https://cdn.jsdelivr.net/npm/fast-grid-layout@0.1/dist/fast-grid-layout.min.js';\n\n  const container = document.getElementById('layout');\n\n  const config = {\n    columns: 12,\n    rowHeight: 40,\n    gap: 10,\n  };\n\n  // Format compatible with React Grid Layout.\n  const layout = [\n    { x: 0, y: 0, w: 3, h: 3, i: 'a' },\n    { x: 3, y: 0, w: 6, h: 3, i: 'b' },\n    { x: 3, y: 3, w: 3, h: 2, i: 'c' },\n  ];\n\n  const gridLayout = new GridLayout(container, config);\n  gridLayout.setLayout(layout);\n  gridLayout.setEditable(true);\n\u003c/script\u003e\n```\n\n### React\n\nYou'll need a thin wrapper component, for example:\n\n```js\nimport { useEffect, useRef } from 'react';\nimport { GridLayout as GridLayoutController } from 'fast-grid-layout';\n\nfunction GridLayout({ config, layout, editable, onLayoutChange, children }) {\n  const containerRef = useRef(null);\n  const controllerRef = useRef(null);\n\n  useEffect(() =\u003e {\n    if (!containerRef.current) return;\n\n    const controller = new GridLayoutController(containerRef.current, config);\n    controllerRef.current = controller;\n\n    return () =\u003e controller.disconnect();\n  }, []);\n\n  useEffect(() =\u003e {\n    const controller = controllerRef.current;\n\n    if (!controller) return;\n\n    controller.setConfig(config);\n    controller.setEditable(editable);\n    controller.setLayout(layout);\n    controller.onLayoutChange(onLayoutChange);\n  }, [config, editable, layout, onLayoutChange, children]);\n\n  return \u003cdiv ref={containerRef}\u003e{children}\u003c/div\u003e;\n}\n```\n\nThe component can be used like this (note the extra `data-key`):\n\n```js\nfunction App() {\n  const config = {\n    columns: 12,\n    rowHeight: 40,\n    gap: 10,\n  };\n\n  // Format compatible with React Grid Layout.\n  const layout = [\n    { x: 0, y: 0, w: 3, h: 3, i: 'a' },\n    { x: 3, y: 0, w: 6, h: 3, i: 'b' },\n    { x: 3, y: 3, w: 3, h: 2, i: 'c' },\n  ];\n\n  return (\n    \u003cdiv\u003e\n      \u003ch1\u003eFast Grid Layout\u003c/h1\u003e\n      \u003cGridLayout config={config} layout={layout} editable\u003e\n        {layout.map((item) =\u003e (\n          \u003cdiv key={item.i} data-key={item.i}\u003e\n            {item.i.toUpperCase()}\n          \u003c/div\u003e\n        ))}\n      \u003c/GridLayout\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\n## Configuration\n\n```js\nconst gridLayout = new GridLayout(container, {\n  columns: 12 // Number of columns in the grid (default: 12).\n  rowHeight: 30, // Height of each row in pixels (default: 30).\n  gap: 0, // Gap between grid cells (applies to both rows and columns, default: 0).\n  columnGap: 0, // Horizontal gap between grid columns in pixels (default: gap).\n  rowGap: 0, // Vertical gap between grid rows in pixels (default: gap).\n  breakpoints: { // Named breakpoint configurations.\n    sm: {\n      maxWidth: 640, // Maximum container width for this breakpoint.\n      columns: 6, // Each breakpoint may override columns, gaps, etc.\n    },\n    md: {\n      maxWidth: 1024,\n      columns: 8\n    },\n    // Largest breakpoint \"default\" is implicitly defined (maxWidth: Infinity).\n  }\n});\n\n// Set config dynamically.\ngridLayout.setConfig({ /* See above. */ });\n\n// Toggle editing (default: off).\ngridLayout.setEditable(true);\n\n// Set layout change callback (there can only be one).\ngridLayout.onLayoutChange((layout, breakpoint) =\u003e {\n  // Handle layout change.\n  // Second argument is the breakpoint name for which the layout was changed.\n});\n\n// Set selection change callback (there can only be one).\ngridLayout.onSelectionChange((selection) =\u003e {\n  // Handle selection change.\n});\n```\n\n## Performance\n\nFGL's scripting overhead is negligible, so performance is usually limited by the\nwork the browser needs to do (animations in particular). For example, here's a\nprofile of 4 seconds of dragging 1 item in a 1000 item layout with FGL:\n\n\u003cimg src=\"./docs/assets/fgl-profile.png\" width=\"640\"\u003e\n\nFor comparison, here's a profile of 4 seconds of dragging 1 item in a 1000 item\nlayout with RGL (scripting overhead is blocking the main thread entirely):\n\n\u003cimg src=\"./docs/assets/rgl-profile.png\" width=\"640\"\u003e\n\nNote that the \"rising tide\" layout compaction algorithm developed here has\neventually made its way into React Grid Layout, see\n[#2152](https://github.com/react-grid-layout/react-grid-layout/pull/2152) and\n[#2184](https://github.com/react-grid-layout/react-grid-layout/pull/2184). The\nprofiles above were recorded before that.\n\n## Notes\n\n- Do not modify layout arrays or items in-place (always make copies). FGL treats\n  layouts as immutable and may cache based on object identity.\n- Set the `content` class on content elements inside items. This disables item\n  selection and dragging when clicking/tapping these elements, but enables text\n  selection and other standard browser behavior.\n- You may further customize FGL by extending the `GridLayout` class and\n  overriding methods and static functions. However, only the public interface of\n  `GridLayout` should be considered stable (semantic versioning).\n\n## Contributing\n\nIssues and PRs welcome!\n\n## TODO\n\n- Test more browser/OS combinations\n- Describe/streamline server-side rendering\n- Document CSS classes\n- Write (more) tests\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorris%2Ffast-grid-layout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorris%2Ffast-grid-layout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorris%2Ffast-grid-layout/lists"}