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

dash-dynamic-grid-layout

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dash-dynamic-grid-layout

Grid layout system for moving components around.

  • 0.1.1
  • PyPI
  • Socket score

Maintainers
1

Dash Dynamic Grid Layout

Dash Dynamic Grid Layout is a Dash component library that provides a flexible grid layout system for arranging and moving components within a Dash application.

Dynamic Grid Example

Special thanks to BSDev BSd3v for contributing the improvements and bug fixes making this a much more polished project.

Features

  • Drag-and-drop functionality for rearranging components
  • Resizable grid items
  • Customizable layout with responsive breakpoints
  • Option to add or remove items dynamically
  • Customizable drag handles for each item
  • Persistence of component state
  • Local, memory, or session storage for persistence

Installation

pip install dash-dynamic-grid-layout

Usage

Here's a basic example of how to use the DashGridLayout component:

import dash_dynamic_grid_layout as dgl
from dash import Dash, html, dcc
import plotly.express as px

app = Dash(__name__)

df = px.data.iris()

app.layout = html.Div([
    dgl.DashGridLayout(
        id='grid-layout',
        children=[
            dgl.DraggableWrapper(
                children=[
                    html.Div('Drag me!', style={'height': '100%', 'display': 'flex', 'alignItems': 'center', 'justifyContent': 'center', 'border': '1px solid #ddd', 'borderRadius': '5px'})
                ],
                handleText='Move'
            ),
            dgl.DraggableWrapper(
                children=[
                    dcc.Graph(
                        figure=px.scatter(df, x="sepal_width", y="sepal_length", color="species"),
                        style={'height': '100%'}
                    )
                ],
                handleText='Move Graph'
            )
        ],
        rowHeight=150,
        cols={'lg': 12, 'md': 10, 'sm': 6, 'xs': 4, 'xxs': 2},
        style={'height': '600px'},
    )
])

if __name__ == '__main__':
    app.run_server(debug=True)

Prop Reference

DashGridLayout

DashGridLayout is a flexible grid layout system for arranging and moving components within a Dash application. These are the properties available for the DashGridLayout component:

PropertyTypeDefaultDescription
idstring-The ID used to identify this component in Dash callbacks.
classNamestring'layout'CSS class name for the grid layout.
rowHeightnumber100The height of a single row in pixels.
colsobject{lg: 12, md: 10, sm: 6, xs: 4, xxs: 2}An object containing breakpoints and column numbers.
styleobject-Inline styles for the grid layout.
itemCountnumber-The number of items in the grid.
itemToRemoveany''The item in the grid that should be removed when triggered.
compactTypestring'vertical'Compaction type. Can be 'vertical', 'horizontal', or null.
showRemoveButtonbooleantrueWhether to show remove buttons for grid items.
showResizeHandlesbooleantrueWhether to show resize handles for grid items.
persistenceboolean-Whether to persist the component's state.
persisted_propsarray['itemLayout']List of props to persist.
persistence_typestring'local'Type of persistence. Can be 'local', 'memory', or 'session'.
itemsarray[]List of items to be rendered in the grid.
itemLayoutarray[]Layout configuration for each item. Each item should be an object with shape {i: string, x: number, y: number, w: number, h: number}.
currentLayoutarray[]The current layout of the grid items. Each item should be an object with shape {i: string, x: number, y: number, w: number, h: number}.
breakpointsobject{lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0}Breakpoints for responsive layout.
breakpointDataobject-Data about the current breakpoint and columns. Shape: {newBreakpoint: string, newCols: number}.

Callbacks

PropertyDescription
setPropsCallback function to update Dash props.

DraggableWrapper

DraggableWrapper is a component that wraps other components and makes them draggable. These are the properties available for the DraggableWrapper component:

PropertyTypeDefaultDescription
childrennode-The content to be wrapped and made draggable
handleBackgroundstring"rgb(85,85,85)"Background color of the drag handle
handleColorstring"white"Text color of the drag handle
handleTextstring"Drag here"Text to display in the drag handle

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.

FAQs


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