Convert Figma logo to code with AI

jbaysolutions logovue-grid-layout

A draggable and resizable grid layout, for Vue.js.

7,046
1,488
7,046
260

Top Related Projects

Vue3 Component for draggable and resizable elements.

Quick Overview

Vue Grid Layout is a grid layout system for Vue.js, similar to Gridster. It allows users to create draggable and resizable grid layouts with responsive breakpoints. This library is particularly useful for building dashboards, drag-and-drop interfaces, or any application requiring a flexible grid system.

Pros

  • Easy integration with Vue.js projects
  • Supports responsive layouts with breakpoints
  • Provides draggable and resizable grid items
  • Offers a wide range of customization options

Cons

  • Limited documentation for advanced use cases
  • May have performance issues with a large number of grid items
  • Requires additional setup for server-side rendering
  • Some users report occasional bugs with drag-and-drop functionality

Code Examples

  1. Basic grid layout setup:
<template>
  <grid-layout
    :layout="layout"
    :col-num="12"
    :row-height="30"
    :is-draggable="true"
    :is-resizable="true"
    :vertical-compact="true"
    :use-css-transforms="true"
  >
    <grid-item v-for="item in layout"
               :key="item.i"
               :x="item.x"
               :y="item.y"
               :w="item.w"
               :h="item.h"
               :i="item.i">
      {{ item.i }}
    </grid-item>
  </grid-layout>
</template>

<script>
export default {
  data() {
    return {
      layout: [
        { x: 0, y: 0, w: 2, h: 2, i: '0' },
        { x: 2, y: 0, w: 2, h: 4, i: '1' },
        { x: 4, y: 0, w: 2, h: 5, i: '2' }
      ]
    }
  }
}
</script>
  1. Responsive layout with breakpoints:
<template>
  <grid-layout
    :layout="layout"
    :col-num="12"
    :row-height="30"
    :responsive="true"
    :breakpoints="{ lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 }"
    :cols="{ lg: 12, md: 10, sm: 6, xs: 4, xxs: 2 }"
  >
    <!-- Grid items here -->
  </grid-layout>
</template>
  1. Handling layout changes:
<template>
  <grid-layout
    :layout="layout"
    @layout-updated="onLayoutUpdated"
  >
    <!-- Grid items here -->
  </grid-layout>
</template>

<script>
export default {
  methods: {
    onLayoutUpdated(newLayout) {
      console.log('Layout updated:', newLayout);
      // Handle the updated layout
    }
  }
}
</script>

Getting Started

  1. Install the package:

    npm install vue-grid-layout
    
  2. Import and use in your Vue.js component:

    <template>
      <grid-layout :layout="layout" :col-num="12" :row-height="30">
        <grid-item v-for="item in layout" :key="item.i" :x="item.x" :y="item.y" :w="item.w" :h="item.h" :i="item.i">
          {{ item.i }}
        </grid-item>
      </grid-layout>
    </template>
    
    <script>
    import { GridLayout, GridItem } from 'vue-grid-layout';
    
    export default {
      components: {
        GridLayout,
        GridItem
      },
      data() {
        return {
          layout: [
            { x: 0, y: 0, w: 2, h: 2, i: '0' },
            { x: 2, y: 0, w:
    

Competitor Comparisons

Vue3 Component for draggable and resizable elements.

Pros of vue-draggable-resizable

  • More lightweight and focused on individual element manipulation
  • Offers finer control over individual draggable/resizable elements
  • Easier to integrate into existing layouts or custom grid systems

Cons of vue-draggable-resizable

  • Lacks built-in grid layout functionality
  • Requires more manual work to create complex grid-based layouts
  • May need additional plugins or custom code for advanced features like collision detection

Code Comparison

vue-draggable-resizable:

<vue-draggable-resizable
  :w="100"
  :h="100"
  @dragging="onDrag"
  @resizing="onResize"
  :parent="true">
  <p>Hello World!</p>
</vue-draggable-resizable>

vue-grid-layout:

<grid-layout
  :layout="layout"
  :col-num="12"
  :row-height="30"
  :is-draggable="true"
  :is-resizable="true"
  :vertical-compact="true"
  :use-css-transforms="true"
>
  <grid-item v-for="item in layout"
             :x="item.x"
             :y="item.y"
             :w="item.w"
             :h="item.h"
             :i="item.i">
    {{item.i}}
  </grid-item>
</grid-layout>

The code comparison shows that vue-draggable-resizable focuses on individual element manipulation, while vue-grid-layout provides a complete grid system with predefined layout structures. vue-grid-layout requires more initial setup but offers built-in grid functionality, whereas vue-draggable-resizable is more flexible for custom implementations but may require additional work for complex layouts.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Vue Grid Layout

vue-grid-layout

Documentation Website

What is Vue Grid Layout?

vue-grid-layout is a grid layout system, like Gridster, for Vue.js. Heavily inspired by React-Grid-Layout

Features

  • Draggable widgets
  • Resizable widgets
  • Static widgets
  • Bounds checking for dragging and resizing
  • Widgets may be added or removed without rebuilding grid
  • Layout can be serialized and restored
  • Automatic RTL support (resizing not working with RTL on 2.2.0)
  • Responsive

Current version: 2.4.0 (Supports Vue 2.2+)

For legacy browsers, like IE11, use version 2.3.12-legacy

For Vue 2.1.10 and below use version 2.1.3

For Vue 1 use version 1.0.3

Documentation

Check out the Documentation Website

Projects using vue-grid-layout

Know of others? Create a PR to let me know!

Contribute

If you have a feature request, please add it as an issue or make a pull request.

Developed by JBay Solutions

NPM DownloadsLast 30 Days